User:Phantomxz/Sandbox: Difference between revisions

From Ylvapedia
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<nowiki><div style="margin-bottom: 10px;">   <input type="checkbox" id="hideCheckbox" style="display: none;"></nowiki>    <nowiki><label for="hideCheckbox" style="cursor: pointer;">Hide Text</label></nowiki>    <nowiki><p id="textToHide" style="margin-top: 5px;">This is the text to hide.</p></nowiki> <nowiki></div></nowiki>
<div style="margin-bottom: 10px;">
    <input type="checkbox" id="hideCheckbox" style="display: none;">
    <label for="hideCheckbox" style="cursor: pointer;">Hide Text</label>
    <span id="textToHide" style="margin-top: 5px;">This is the text to hide.</span>
</div>
 
<script>
document.getElementById('hideCheckbox').addEventListener('change', function() {
    var textToHide = document.getElementById('textToHide');
    textToHide.style.display = this.checked ? 'none' : '';
});
</script>

Revision as of 18:30, 1 June 2024

   <input type="checkbox" id="hideCheckbox" style="display: none;">
   <label for="hideCheckbox" style="cursor: pointer;">Hide Text</label>
   This is the text to hide.

<script> document.getElementById('hideCheckbox').addEventListener('change', function() {

   var textToHide = document.getElementById('textToHide');
   textToHide.style.display = this.checked ? 'none' : ;

}); </script>