Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-02-2002, 11:14 PM   PM User | #1
ovargas
New to the CF scene

 
Join Date: Jun 2002
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
ovargas is an unknown quantity at this point
How do I delete an object in DHTML ???

I've created a Div using a JavaScript and DHTML ... and it worked just fine...

But in order to use the JavaScript again I need to somehow delete the object "Div" that was generated before.

Does anybody knows how to do that ???

How do I delete, release or something to the object in order to re-create it with other atributes ???

Any Ideas???

Thanks a lot.
ovargas is offline   Reply With Quote
Old 07-03-2002, 12:11 AM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
W3C DOM way (works in IE5+/NS6+):

var div = refToDiv //document.getElementById('divID') perhaps
div.parentNode.removeChild(div);

IE-way (IE4+):
refToDiv.outerHTML = '';
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 07-03-2002, 05:37 PM   PM User | #3
ovargas
New to the CF scene

 
Join Date: Jun 2002
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
ovargas is an unknown quantity at this point
Thanks jkd

It worked...

Thanks a lot jkd...

ovargas is offline   Reply With Quote
Old 07-05-2002, 08:21 AM   PM User | #4
premshree
Regular Coder

 
Join Date: Jun 2002
Location: Mumbai, India
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
premshree is an unknown quantity at this point
Hey jkd,

what does this do?
document.getElementById("elemName").style.display="none";
premshree is offline   Reply With Quote
Old 07-05-2002, 08:45 AM   PM User | #5
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
it makes the element not displayed (hidden) not occupying a space in the screen.

Quote:
Originally posted by premshree
Hey jkd,

what does this do?
document.getElementById("elemName").style.display="none";
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 07-05-2002, 08:46 AM   PM User | #6
Zvona
Regular Coder

 
Join Date: May 2002
Location: Helsinki, Finland
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Zvona is an unknown quantity at this point
Quote:
Originally posted by premshree
what does this do?
document.getElementById("elemName").style.display="none";
There are various way to display elements. Current property setting will set that element isn't displayed at all.

Difference between setting element's visibility to hidden and setting element's display to none, is that element do not reserve the space it needs when display property has been set to none.

Read :
http://www.w3schools.com/css/pr_class_display.asp
__________________
Zvona
First Aid for
Web Design
Zvona is offline   Reply With Quote
Old 07-05-2002, 06:03 PM   PM User | #7
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
The element still exists though, it just isn't rendered. Often that is enough, but sometimes you need to truely delete the node using the methods I described above.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 07-05-2002, 06:14 PM   PM User | #8
Bosko
Regular Coder

 
Join Date: Jun 2002
Location: The Netherlands
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Bosko is an unknown quantity at this point
Quote:
Originally posted by jkd
[B]W3C DOM way (works in IE5+/NS6+):

var div = refToDiv //document.getElementById('divID') perhaps
div.parentNode.removeChild(div);/B]
This code should work in Konqueror too
Bosko is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:26 PM.


Advertisement
Log in to turn off these ads.