PDA

View Full Version : Javascript - click to hide/show text/content



Fli
03-11-2015, 01:59 PM
Hello, do You know any effective and simple javascript code which allows showing/hiding some webpage content on click?

so far i found this one:


<script>
function showhide(idecko){
el=document.getElementById(idecko).style;
el.display=(el.display == 'block')?'none':'block';
}
</script>
<style>.hidden {display: none}</style>
<span style="cursor: pointer; cursor: hand;" onclick="showhide('oddil1')">Click me to show/hide</span>
<div id="oddil1" class="hidden">Hidden text here</div>


and it works. By default, text is hidden, when one click it is shown, when click again, it is hidden

NancyHolmes
01-15-2020, 07:20 AM
I suggest you to Google free code camp .
This will definitely help you.

mcdermottraegan
09-27-2020, 02:04 PM
This script seems very difficult to me. Can anybody help me with it?