Lets say I have an element
<a class="Foo Bar" />
And I want to add a duplicate class, so as I code this:
$('.Bar').addClass('Foo');
The class is not added, because the element already has one.
I want to code something like this:
$('.Bar').addClassForcebly('Foo'); // Fake method, only for example.
And I expect the following result:
<a class="Foo Bar Foo" />
I have tried to use the jQuery's addClass method's overload:
$('.Bar').addClass(function(i, c) {
return c + ' Foo';
});
But this does not work either. It just does not add the duplicate class. How do I do that?
The point of this question is pretty simple: I want to make my HTML elements be able to be disabled and enabled mulitple times. If I 'disable' an element twice (adding two same classes) I should 'enable' it twice as well in order for my logic to work.
data-disabled(really faster then using.data).[data-disabled="0"]for zero, and css has:not()for finding non-zero.