Select last item from select menu via Javascript
Description
The following code shows how to select last item from select menu via Javascript.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.4.4.min.js'></script>
<script type='text/javascript'
src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css">
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!-- www. j a va 2 s . c om-->
$(function(){
$('#select-choice-1 option:last').attr("selected", 'true');
$('#select-choice-1').selectmenu('refresh');
});
});//]]>
</script>
</head>
<body>
<div data-role="fieldcontain">
<label for="select-choice-1" class="select">Choose shipping
method:</label> <select style="font-weight: normal" name="select-choice-1"
id="select-choice-1">
<option value="">None</option>
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express" selected>Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
</body>
</html>