Solved

how do i make my tag appear closed?

Posted on 2008-10-16
2
152 Views
Last Modified: 2012-05-07
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
Comment
Question by:runnerjp
2 Comments
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 500 total points
ID: 22733348
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
 

Author Closing Comment

by:runnerjp
ID: 31597325
thankyou worked perfectly
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now