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.
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:
$('#myTabs a').is('.disabled').removeAttr('data-toggle');
Bootply example
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.
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:
$('#myTabs a').is('.disabled').removeAttr('data-toggle');
Bootply example
Share Improve this question edited Jul 7, 2014 at 13:35 Rahul Gupta 10.1k7 gold badges64 silver badges69 bronze badges asked Jul 7, 2014 at 13:27 peterbfpeterbf 2292 gold badges5 silver badges12 bronze badges 3 |2 Answers
Reset to default 15You can try this:-
$('#tabs li.disabled').find('a').removeAttr('data-toggle');
or
$('#tabs li.disabled a').removeAttr('data-toggle');
Demo
$('#myTabs a').is('.disabled') returns a boolean: false - you cannot call removeAttr on this!
Second your disabled class is on your li, not your .
Try this:
$('#myTabs li.disabled a').removeAttr('data-toggle');
<a>
element that is disabled, but actually the class is applied to the<li>
element. – dcclassics Commented Jul 7, 2014 at 13:33li
elements change in your page, or do they remain 'static'? – David Thomas Commented Jul 7, 2014 at 15:21