I'm trying to use addClass on my button with the Bootstrap CSS active class.
However, during debugging it seems to work, but then the addClass('active') action is reversed.
Has anyone encountered this issue before?
Here is my code:
$("#a #b button").click(function (){
if($(this).hasClass("active") == true) {
$(this).removeClass("active");
} else {
$(this).addClass("active");
}
});
and here is my HTML:
<form id="a">
<div class="row">
<div class="btn-group" id="b">
<button ...></button>
<button ...></button>
</div>
</div>
</form>
To elaborate further, the issue is not with the 'WORKING addClass' function as it does work. However, at some points in the jQuery processing, the class 'active' seems to disappear.
Can anyone offer assistance?