JS Hide Div If It Has A Class Added Via JS
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 w
Solution 1:
$(document).ready(function(){
$('section').click(function(){
$(this).addClass('active');
if($('section').hasClass('active')){
$('ul#menu').hide();
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section>check</section>
<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>
Solution 2:
oth the section and the li have active classes so you could use something like this or use the afterSlideLoad
event if it is depeding of the slideshow
$(window).on("scroll",function() {
if ($('#menu li:last-child').hasClass("active")) {
("#menu").fadeOut("fast")
}
})
or you can use slideIndex to check if you are on the last slide. see here > afterSlideLoad
Post a Comment for "JS Hide Div If It Has A Class Added Via JS"