我编写了一个当前在 Click 事件上运行的 jQuery 函数。我需要更改它,以便它在下拉框 (Select-Option) 值更改时运行。这是我的代码:
<form id="form1" name="form1" method="post" action="">
<label>
<select name="otherCatches" id="otherCatches">
<option value="*">All</option>
</select>
</label>
</form>
$("#otherCatches").click(function() {
$.ajax({
url: "otherCatchesMap.php>",
success: function(msg) {
$("#results").html(msg);
}
});
});
最佳答案
使用change()
代替click()
:
jQuery(document).ready(function(){
$("#otherCatches").change(function() {
$.ajax({
url: "otherCatchesMap.php>",
success: function(msg){
$("#results").html(msg);
}
});
});
});
关于javascript - 在下拉更改时运行 jQuery 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4910795/