Lets say I have two divs: "A" and "B". I want to add "disabled" class to the div "A" as long as the div "B" has an "active" class.
How should I do this with jquery? I tried "hasClass" method but it didn't work.
Lets say I have two divs: "A" and "B". I want to add "disabled" class to the div "A" as long as the div "B" has an "active" class.
How should I do this with jquery? I tried "hasClass" method but it didn't work.
If you want div "A" to always have a class disabled when div "B" has class active, add a listener. That way, when you add class active dynamically, div "A" is updated too.
$('#parent-of-a').bind('DOMSubtreeModified', function(e) {
if ($('.b').hasClass('active')){$('.a').addClass('disabled')}
});
can you try it?
if($(".b:has('.active')") { $('.a').addClass('disabled'); }