JavaScript を使用して、要素の非表示と表示をトグルします。
<button onclick="myFunction()">Click Me</button>
<div id="myDIV">
This is my DIV element.
</div>
function myFunction() {
var x = document.getElementById('myDIV');
if (x.style.display
=== 'none') {
x.style.display = 'block';
} else {
x.style.display =
'none';
}
}
Try it Yourself »