In this below script, dynamically set the selected option of a drop-down list using JQuery, Javascript and html

SCRIPT
<script type="text/javascript">
$(function(){
$("#gender").val("Male").attr('selected','selected");
});
</script>
HTML
<select id="gender" selected="selected">
<option>--Select--</option>
<option value="1">Male</option>
<option value="2">Female</option>
</select>
<script type="text/javascript">
$(function(){
$("#gender").val("Male").attr('selected','selected");
});
</script>
HTML
<select id="gender" selected="selected">
<option>--Select--</option>
<option value="1">Male</option>
<option value="2">Female</option>
</select>
No comments:
Post a Comment