User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 375,172 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,102 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1335 | Replies: 1
Reply
Join Date: Sep 2006
Posts: 9
Reputation: narsto is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
narsto narsto is offline Offline
Newbie Poster

help with this hiding text example Javascript

  #1  
Nov 5th, 2006
[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head>
<title></title>
<style type="text/css">
.nodisplay{
display: none;
}
</style>

<script type="text/javascript">
<!--
var theElement;
theElement = document.getElementById("test");
theElement.className="nodisplay";
-->
</script>

</head>
<body>
<div id="test"> CSS Rules in Action </div>
</body>
</html>]

I want this text to disappear, but I get object theElement is undefined or null. Help I think it is simple
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: help with this hiding text example Javascript

  #2  
Nov 6th, 2006
<div id="test"> doesn't exist when your script is being run. Usually, when you are working with the DOM, you would like to wait untill the whole DOM is loaded.

try running your code afer the window is loaded.

window.onload = function() {

// .. your code

};

or use the specific event attachment functions for different browsers.

Edit: I meant "event handler" attachment functions...
Last edited by digital-ether : Nov 6th, 2006 at 1:04 am.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC