.prop(" disabled")mehtod不适用于chrome [英] .prop("disabled") mehtod doesn't work on chrome

查看:108
本文介绍了.prop(" disabled")mehtod不适用于chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.prop(disabled)方法来获取已禁用div的数量。它在IE浏览器(Internet Explorer)上运行时表现正确,但对于Chrome浏览器没有显示相同的行为。

以下是我使用的代码:

$(' #UserEditShopList li .accountText')。each(function(){

if($(this).prop(disabled)){

countEnabled ++

}

});

解决方案

('#UserEditShopList li .accountText')。each(function(){

if(


(this).prop(disabled)){

countEnabled ++

}

});


如果你正在使用jQuery< 1.6执行此操作:

 jQuery .attr( 已禁用'  disabled'); 





如果您使用的是jQuery 1.6+:

 jQuery .prop(  已禁用 true ); 





请参阅此问题: .prop() vs .attr()以获取参考原因。
或者你可以试试这个:

。attr( 已禁用' 已禁用'); 


I'm using .prop("disabled") method to get the number of disabled div. it behaves correct when run on IE(Internet Explorer) but doesn't show up the same behavior for chrome browser.
below is the code i used:
$('#UserEditShopList li .accountText').each(function () {
if ($(this).prop("disabled")) {
countEnabled++
}
});

解决方案

('#UserEditShopList li .accountText').each(function () {
if (


(this).prop("disabled")) {
countEnabled++
}
});


If you are using jQuery < 1.6 do this:

jQuery .attr("disabled", 'disabled');



If you are using jQuery 1.6+:

jQuery .prop("disabled", true);



See this question: .prop() vs .attr() for references why.
Or you can try this:

.attr("disabled", 'disabled');


这篇关于.prop(&quot; disabled&quot;)mehtod不适用于chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆