我有一些 JQuery,如果返回特定结果,我想用它来禁用 php 页面上的按钮。
查询
...
success:function(data){
$("#value10").html(data.price);
$("#total").html(data.newtotal);
$("#toohigh").html(data.toohigh);
if(data.toohigh === 1) {
$("#subbut").attr('disabled', 'disabled');
} else if(data.toohigh === 0){
$("#subbut").attr('disabled', 'disabled');
}
php
<button type="submit" name="Submit" class="btn btn-primary align-content-center" id="subbut">
我尝试了各种不同的可能解决方案,但没有一个在data.toohigh
等于 1时禁用按钮
我错过了什么?
它是由您的变量data.toohigh
与您的条件1
或0
数据类型不匹配引起的
试试这个代码
...
success:function(data){
$("#value10").html(data.price);
$("#total").html(data.newtotal);
$("#toohigh").html(data.toohigh);
if(data.toohigh == '1') {
$("#subbut").attr('disabled', 'disabled');
} else if(data.toohigh == '0'){
$("#subbut").attr('disabled', 'disabled');
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句