Get selected value and text from select control
Description
The following code shows how to get selected value and text from select control.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type="text/javascript"
src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css">
<script type='text/javascript'>
$(window).load(function(){<!--from www . j ava 2s . com-->
$("#location").change(function() {
alert('Location Changed value: '+$('#location option:selected').val()+' text: '+$('#location option:selected').text());
});
});
</script>
</head>
<body>
<div data-role="page" id="locationPage">
<div id="container">
<form id="theForm">
<select name="location" id="location">
<option value="1">Option1</option>
<option value="2">Option2</option>
</select>
</form>
</div>
</div>
<!-- /page -->
</body>
</html>