javascript - Jquery - Show current div when click a link and hide others -


when click on show/hide link shows both divs , want show related div. how can that? don't want use id's each div.

jsfiddle

<div class="main-box">     <a href="#" class="show_hide">show/hide</a>      <div class="slidingdiv">     first div.     </div> </div>  <br/>  <div class="main-box">     <a href="#" class="show_hide">show/hide</a>      <div class="slidingdiv">     second div.     </div> </div> 

and

$(document).ready(function(){     $(".slidingdiv").hide();     $(".show_hide").show();      $('.show_hide').click(function(){     $(".slidingdiv").slidetoggle();     }); }); 

into click function, change code this:

$(".slidingdiv").slideup();     $(this).next().slidetoggle(); 

https://jsfiddle.net/pzc8vy9b/6/


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -