if i have a dropdown with the following html:
开发者_运维技巧 <select id="myDropdown" name="myDropdown">
<option value="6">Six</option>
<option value="5">Five</option>
<option value="3">Three</option>
<option value="1">One</option>
</select>
how can i have this dropdown change to a specific selected value after i click on a button?
If your button is id="myButton"
you can do it like this:
$("#myButton").click(function() {
$("#myDropdown").val(1); //1 being whatever value you want to set
});
try this
jQuery(document).ready(function(){
$(".mybuttonclass").click(function() {
$(".myDropdownclass").val(value for that dropdown items);
});
});
精彩评论