Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.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/87.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 document.body on change/select on change不触发,无错误——jquery 1.3.1_Javascript_Jquery - Fatal编程技术网

Javascript document.body on change/select on change不触发,无错误——jquery 1.3.1

Javascript document.body on change/select on change不触发,无错误——jquery 1.3.1,javascript,jquery,Javascript,Jquery,我仅限于在此项目中使用jquery 1.3.1,因此无法更新jquery。我正在尝试使一个选择字段在更改时禁用另一个选择字段 我试过这个: $(document.body).on('change','#idoffirstselect',function(){ var selected = $("#idoffirstselect").val(); if (selected == "foo") { $("#selecttwo").attr('disabled','disa

我仅限于在此项目中使用jquery 1.3.1,因此无法更新jquery。我正在尝试使一个选择字段在更改时禁用另一个选择字段

我试过这个:

$(document.body).on('change','#idoffirstselect',function(){
    var selected = $("#idoffirstselect").val();
    if (selected == "foo") {
      $("#selecttwo").attr('disabled','disabled');
    } else {
      $("#selecttwo").removeAttr('disabled');
    }  
 });
这是:

$( "#idoffirstselect" ).change(function(){
  var selected = $("#idoffirstselect").val();
  if (selected == "foo") {
    $("#selecttwo").attr('disabled','disabled');
  } else {
    $("#selecttwo").removeAttr('disabled');
  }  
});

有什么建议吗?还有什么我可以试试的吗?Firebug没有显示任何错误

由于
上的
1.7之前的版本中不可用,请尝试在此处使用:

.on()
直到1.7版才添加到jQuery。
$(function() {
    $('select').live('change', function(){
        var selected = $("#idoffirstselect").val();
        if (selected == "foo") {
            $("#selecttwo").attr('disabled','disabled');
        } else {
            $("#selecttwo").removeAttr('disabled');
        }  
    });
});