I am trying to show/hide a specific div by id depending on which button is selected, however while the correct content is being displayed, the rest of the page is being hidden. I would like that the buttons are kept on display whereas only the divs
with the class name of material
get hidden or shown depending on which button is selected. What is a possible way to fix this?
Code
$(document).ready(function() {
$(".bob").click(function() {
var divname = this.value;
$("#material" + divname).show().siblings().hide();
});
});
.material {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div id="type1" class="type">
<h3>1.2 Select material v1</h3>
<button class="bob" type="button" name="material" value="1">tiles 1</button>
<button class="bob" type="button" name="material" value="2">tiles 2</button>
<button class="bob" type="button" name="material" value="3">tiles 3</button>
</div>
<div id="material1" class="material">
1
</div>
<div id="material2" class="material">
2
</div>
<div id="material3" class="material">
3
</div>