I have this script that will get executed when i click a button. When the button is clicked the text below will collapse and when i click on the button again the text will be expanded and viewed.
But, what i want is the opposite. When the page loads it self i want to hide/collapse the text and only display upon clicking on the button.
How can i make that change?
JS
function toggleMe(a) {
var e = document.getElementById(a);
if (!e)
return true;
if (e.style.display == "none") {
e.style.display = "block"
} else {
e.style.display = "none"
}
return true;
}
HTML
<input type="button" ="return toggleMe('para1')" value="Toggle">
<br>
<p id="para1">
some text................ </p>
1 Answer