How can I make an element, so that it is hided first, and then when I tap to show, it is showed? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I make an element, so that it is hided first, and then when I tap to show, it is showed?

22nd Dec 2017, 1:48 AM
Sanjaykumar Rathod
2 Answers
+ 5
use javascript <p id='paragraph' style='display: none'>test</p> <button id='btn'>show</button> <script> button = document.getElementById('btn'); paragraph = document.getElementById('paragraph'); button.onclick = function() { if (paragraph.style.display == 'none') { paragraph.style.display = 'block'; } else { paragraph.style.display = 'none'; } } </script>
22nd Dec 2017, 2:08 AM
Amethyst Animion
Amethyst Animion - avatar
+ 2
If you check jQuery tutorial, there are describe how to hide/show elements on some events it is a first lesson in effects module.
22nd Dec 2017, 1:54 AM
Dima Makieiev
Dima Makieiev - avatar