CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   HTML & CSS (http://www.codingforums.com/forumdisplay.php?f=13)
-   -   How do I delete an object in DHTML ??? (http://www.codingforums.com/showthread.php?t=1271)

ovargas 07-02-2002 11:14 PM

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.

jkd 07-03-2002 12:11 AM

W3C DOM way (works in IE5+/NS6+):

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

IE-way (IE4+):
refToDiv.outerHTML = '';

ovargas 07-03-2002 05:37 PM

Thanks jkd
 
It worked...

Thanks a lot jkd...

:thumbsup:

premshree 07-05-2002 08:21 AM

Hey jkd,

what does this do?
document.getElementById("elemName").style.display="none";

glenngv 07-05-2002 08:45 AM

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";


Zvona 07-05-2002 08:46 AM

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

jkd 07-05-2002 06:03 PM

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.

Bosko 07-05-2002 06:14 PM

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 ;)


All times are GMT +1. The time now is 03:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.