I’ve made this code to show me a div when I click on a box:
JS
<script type="text/javascript">
var bool = 0;
function showDiv() {
if (bool == 1) {
bool = 0;
document.getElementById('show').style.visibility = "hidden";
} else if (bool == 0) {
bool = 1;
document.getElementById('show').style.visibility = "visible";
}
}
</script>
HTML
<input type="button" value="click" onclick="showDiv();" />
<div id="show" style=" visibility:hidden;">
<p>it is okay it is okay it is okay it is okay it is okay</p>
</div>
But, how do I do this when it’s an image I want to click on to show the div.
When you tag your question jquery, then I recommend using
.togglemethod instead..