twitter-bootstrap 禁用时删除数据切换属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24611727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove data-toggle attribute when disabled
提问by peterbf
I have a list of tabs with elements that can be disabled - i.e. non-clickable. And when 'disabled' is added as a class, then the mouse over on the element is indicating that the tab is non-clickable. Unfortunately the element is clickable.
I am trying to remove the datatoggle="tab"from the element when the element is disabled, but my jQuery skills aren't sufficient.
我有一个选项卡列表,其中包含可以禁用的元素 - 即不可点击。当“禁用”作为一个类添加时,鼠标悬停在元素上表示该选项卡不可点击。不幸的是,该元素是可点击的。datatoggle="tab"当元素被禁用时,我试图从元素中删除,但我的 jQuery 技能还不够。
I have a ul of class="nav nav-tabs" with id="myTabs"And I'm trying to remove the data-toggle attribute with this jQuery statement:
我有一个 ulclass="nav nav-tabs" with id="myTabs"并且我正在尝试使用此 jQuery 语句删除 data-toggle 属性:
$('#myTabs a').is('.disabled').removeAttr('data-toggle');
回答by Mohit Kumar
回答by rob
$('#myTabs a').is('.disabled') returns a boolean: false - you cannot call removeAttr on this!
$('#myTabs a').is('.disabled') 返回布尔值:false - 您不能对此调用 removeAttr!
Second your disabled class is on your li, not your .
其次,您的残疾人课程在您的 li 上,而不是您的 .
Try this:
试试这个:
$('#myTabs li.disabled a').removeAttr('data-toggle');

