• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

how do i make my tag appear closed?

i have a button that hides and shows text.... but i cant figure out how to make it so it hides the text before hand?
function initialise() {
var element = document.getElementById('element-id');
 
if (element && element.style)
element.style.display = 'none';
}
 
function toggleDisplay(element) {
var style;
 
if (typeof element == 'string')
element = document.getElementById(element);
if (element && (style = element.style))
style.display = (style.display == 'none') ? '' : 'none';
}
 
if (!document.getElementById)
document.getElementById = function() {return null;};
 
 
<body onload="initialise();">
<!-- ... -->
<div id="element-id">Content to be hidden.</div>
<input type="button" value="Toggle content" onclick="toggleDisplay('element-id');">
<!-- ... -->
</body>

Open in new window

0
runnerjp
Asked:
runnerjp
1 Solution
 
MatthiasVanceCommented:
You can change your code this way in order for your text to be initially invisible.

Kind regards,

Matthias Vance
<div id="element-id" style="display: none;">Content to be hidden.</div>

Open in new window

0
 
runnerjpAuthor Commented:
thankyou worked perfectly
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now