$("input[type=checkbox]").click(function(){
alert("clicked");
if($('#result').html().length) {
$('button[type="submit"]').attr('disabled','disabled');
} else { $('button[type="submit"]').removeAttr('disabled'); }
});
上述代码my if语句未运行。 如果我在控制台中运行if语句,它运行良好,但只要将它嵌入到click函数中即可。该警报显示,但我的提交框不灰色。JQuery if语句未运行
任何人都知道我的代码有什么问题。
是它包裹着'$(文件)。就绪()',哪些因素是'#result'? alert()是否被执行? –
尝试使用'prop'方法: '$('button [type =“submit”]')。prop('disabled',true);' – undefined
如果我在控制台中单独运行代码,但是,只要我嵌入代码,这部分不会运行$('button [type =“submit”]')。attr('disabled','disabled'); –