在下拉更改时运行jQuery函数
我编写了一个当前在Click事件上运行的jQuery函数。 我需要更改它,以便在更改下拉框(Select- Option)值时运行它。 这是我的代码:
$("#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); } }); }); });
$(function() { $("#otherCatches").change(function() { $(this).val() // how to get the value of the selected item if you need it }); });
$("#otherCatches").change(function () { //// Your code });
$("#otherCatches").change(function () { //// Your code });