Show One Div Correspond To The Button Click
B1
B2
Solution 2:
Jquery
HideDiv();
$('.sprite-big').on("click", function() {
showHide($(this).prop('id'))
});
function showHide(id) {
HideDiv();
var id = '#D' + id;
$(id).show();
}
function HideDiv() {
$('#D1').hide();
$('#D2').hide();
$('#D3').hide();
}
Solution 3:
I've just posted this exact question a moment ago.
Try this :
<script>
$('#place').on('change', function() {
if ( this.id== '1');
{
$("#D1").show();
$("#D2").hide();
$("#D3").hide();
}
else if ( this.id== '2');
{
$("#D1").hide();
$("#D2").show();
$("#D3").hide();
}
else if ( this.id== '3');
{
$("#D1").hide();
$("#D2").hide();
$("#D3").show();
}
else
{
$("#D1").show();
$("#D2").show();
$("#D3").show();
}
});
});
</script>
<div id="D1">Some content</div>
<div id="D2">Some content</div>
<div id="D3">Some content</div>
<div id = place>
<div class="sprite-big not-visited" id="1">B1</div>
<div class="sprite-big not-visited" id="2">B2</div>
<div class="sprite-big not-visited" id="3">B3</div>
</div>
Post a Comment for "Show One Div Correspond To The Button Click"