Skip to content Skip to sidebar Skip to footer

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();

}
});

});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><section>check</section><ulid="menu"><lidata-menuanchor="slide1"><ahref="#slide1"><span></span></a></li><lidata-menuanchor="slide2"><ahref="#slide2"><span></span></a></li><lidata-menuanchor="slide3"><ahref="#slide3"><span></span></a></li><lidata-menuanchor="slide4"><ahref="#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"