I'm trying to show multiple div when a button is clicked. For instance, I want to show all the divs with id=div1 only when Button1 is clicked. Likewise, show all the divs with id=div2 only when Button2 is clicked. The same goes for other slides too in increasing number.
HTML:
<div class="container">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="divA">
<div class="divAA">
<div id="div1" class="targetDiv">
<p>Div1 Intro: Hidden until Button1 is clicked</p>
</div>
</div>
<p>
Div1 Short to be shown by default.
<span id="div1" class="targetDiv">Hidden span until Button1 is clicked</span>
</p>
<a class="showSingle" target="1">Button1</a>
<div class="divAAA">
<div id="div1" class="targetDiv">
<p>
Div1 Details: Hidden until Button1 is clicked.
</p>
</div>
</div>
</div>
</div>
<div class="item">
<div class="divB">
<div class="divBB">
<div id="div2" class="targetDiv">
<p>Div2 Intro: Hidden until Button1 is clicked
<span id="div2" class="targetDiv">Hidden span until Button1 is clicked</span>
</p>
</div>
</div>
<p>
Div2 Short
</p>
<a class="showSingle" target="2">Button2</a>
<div id="div2" class="targetDiv">
<p>
Div2 Details: Hidden until Button2 is clicked. Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked.Div2 Details: Hidden until Button2 is clicked. YOLO.
</p></div>
</div>
</div>
<div class="item">
3
</div>
<div class="item">
4
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Javascript:
jQuery(function(){
jQuery('.showSingle').click(function(){
jQuery('.targetDiv').hide();
jQuery('#div'+jQuery(this).attr('target')).show();
});
});