I am programming a web and i need to know when a Class was added. I am using a JavaScript plugin and the plugin add a CSS Class in then deletes it and add it in other div (gallery). I need to know in every moment in which 'div' is this class.
Here you have an example of what I want to do
$('div').click(function() {
$(this).toggleClass('red');
});
if ($('div').hasClass("red")) {
$("div").addClass('border');
}
.box {
width: 250px;
height: 100px;
border: 1px #000 solid;
}
.red {
background: red;
}
.border {
border: 6px #000 solid;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='box'></div>
As you see in this example, I want to add the class border
only when the class red
was added, can not do it together with the class red
because as i say in the real page I am using a JavaScript plugin.