Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在下拉列表更改时运行jQuery函数_Javascript_Jquery - Fatal编程技术网

Javascript 在下拉列表更改时运行jQuery函数

Javascript 在下拉列表更改时运行jQuery函数,javascript,jquery,Javascript,Jquery,我编写了一个jQuery函数,当前在Click事件上运行。我需要更改它,以便它在下拉框(选择选项)值更改时运行。这是我的密码: <form id="form1" name="form1" method="post" action=""> <label> <select name="otherCatches" id="otherCatches"> <option value="*">All</option>

我编写了一个jQuery函数,当前在Click事件上运行。我需要更改它,以便它在下拉框(选择选项)值更改时运行。这是我的密码:

<form id="form1" name="form1" method="post" action="">
  <label>
    <select name="otherCatches" id="otherCatches">
      <option value="*">All</option>
    </select>
  </label>
</form>
使用
change()
而不是
click()


.change()非常适合列表我知道这类注释是不受欢迎的,但是:在Google上搜索
jquery change
会为您提供指向
change()
函数的链接作为第一次点击:
$("#otherCatches").click(function() {
    $.ajax({
        url: "otherCatchesMap.php>",
        success: function(msg) {
            $("#results").html(msg);
        }
    });
});
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        
});