jquery - using not function with $this and is(":visible") -
i have following html...
<button>one</button> <div class="div1"></div> <button>two</button> <div class="div2"></div> <button>three</button> <div class="div3"></div> <button>four</button> <div class="div4"></div>
and jquery have used....
$(document).ready(function(){ $("button").click(function(){ $(this).next().slidetoggle(); }); });
i use slidetoggle()
function (that hide) again if others open(visible). how use not
function $this
, is(":visible")
while other visible clicked adjacent div shown , others closed?
like this?
$(document).ready(function(){ $("button").click(function(){ $(this).next().slidetoggle().siblings('[class^=div]').slideup(); }); });
you dont need use :visible
slideup. slide siblings div particular class pattern.
or since want use :visible , not:
$(document).ready(function(){ $("button").click(function(){ $('[class^=div]:visible').not($(this).next().slidetoggle()).slideup(); //select class pattern visible slideup (provide container possibly) //but exclude clicked element's next div , slidetoggle simultaneously. }); });
Comments
Post a Comment