?
Solved

how do i make my tag appear closed?

Posted on 2008-10-16
2
Medium Priority
?
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

771 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