We can apply the CSS effect on the HTML section using JavaScript. So we can apply any CSS property to the HTML tag or section. Using button on click we are interested to perform following events.
<p id='myparagraph'> Courtesies cannot be borrowed like snow shovels; you must have some of your own. </p>
<script type="text/javascript">
function showhide()
{
paragraph = document.getElementsByTagName('p')[0];
if (paragraph.style.display === "none") // Currently is Hide
{
paragraph.style.display = "block"; // To Show
}
else // Currently is Show
{
paragraph.style.display = "none"; // To Hide
}
}
</script>
Courtesies cannot be borrowed like snow shovels; you must have some of your own.
<button onclick="showhide()"> Click me to Hide & Show </button>
<p id='myparagraph'> Courtesies cannot be borrowed like snow shovels; you must have some of your own. </p>
<script type="text/javascript">
function showhide()
{
paragraph = document.getElementById('myparagraph');
if (paragraph.style.display === "none") // Currently is Hide
{
paragraph.style.display = "block"; // To Show
}
else // Currently is Show
{
paragraph.style.display = "none"; // To Hide
}
}
</script>