I am working on a code where an active
class is added to a div via JS.
What I would like to do is, when that div has active
class, hide another div. But, due to the active
class was added via JS, this code doesn't work:
if($("#section3").hasClass("active")) {
$(".menu").fadeOut("fast");
}
I think I would need to use the on function: .on()
Something like this, but it's not working... Any ideas?
$("#section3").on( function() {
$(this).hasClass('active') {
$(".menu").fadeOut("fast");
}
});
EDITED:
I'm afraid I cannot paste the code because I am using a plugin. This is the one that I am using, so you can see the functionality there.
I've added this bullet menu to it:
<ul id="menu">
<li data-menuanchor="slide1"><a href="#slide1"><span></span></a></li>
<li data-menuanchor="slide2"><a href="#slide2"><span></span></a></li>
<li data-menuanchor="slide3"><a href="#slide3"><span></span></a></li>
<li data-menuanchor="slide4"><a href="#slide4"><span></span></a></li>
</ul>
Each slide has a active class
when it's on viewport, so what I would like to achieve is when the last slider is active, hide the menu