Solved

how do i make my tag appear closed?

Posted on 2008-10-16
2
151 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

758 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

19 Experts available now in Live!

Get 1:1 Help Now