Bikshu s Bikshu s - 21 days ago 5
Javascript Question

How to hide clicked element when all having same parent class

How to hide caption of particular slide which user clicked. Here having same class name for all the slides is making big problem. How to over come this.

<div id="accordion-wrapper">
<div class="slide">
<div id="mask"></div> <img src="snd/images/slider1.jpg" />
<div class="caption">
<p> 1</p>
</div>
</div>
<div class="slide">
<div id="mask"></div> <img src="snd/images/slider2.jpg" />
<div class="caption">
<p> 2</p>
</div>
</div>
<div class="slide">
<div id="mask"></div> <img src="snd/images/slider3.jpg" />
<div class="caption">
<p> 3</p>
</div>
</div>
<div class="slide">
<div id="mask"></div> <img src="snd/images/slider4.jpg" />
<div class="caption">
<p> 4</p>
</div>
</div>
<div class="slide">
<div id="mask"></div> <img src="snd/images/slider5.jpg" />
<div class="caption">
<p> 5</p>
</div>
</div>
</div>

Answer
$(".slide").click(function(){
    $(this).find(".caption").hide();
})