php - JQUERY: How do I know if this element is currently open/closed (slidetoggle) -


im using following open/close div

$(".alerts").click(function(){      $(this).toggleclass("active").next().slidetoggle(50); 

but want function trigger if box closed , being opened, how can determine this? prefer not use cookies or that

thanks!

you can use visible selector is method -

$(document).ready(function() {     $(".alerts").click(function()     {                 if($(this).toggleclass("active").next().is(":visible"))             alert("it's visible");          $(this).toggleclass("active").next().slidetoggle(50);     }); }); 

an example on jsfiddle.

the -

if($(this).toggleclass("active").next().is(":visible"))     alert("it's visible"); 

portion checking see if next element of this visible or not. if is, returns true. result, alert method gets executed.

here documentation visible selector , here documentation is() method.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -