...

View Full Version : How do I delete an object in DHTML ???



ovargas
07-03-2002, 12:14 AM
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, 01: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, 06:37 PM
It worked...

Thanks a lot jkd...

:thumbsup:

premshree
07-05-2002, 09:21 AM
Hey jkd,

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

glenngv
07-05-2002, 09:45 AM
it makes the element not displayed (hidden) not occupying a space in the screen.


Originally posted by premshree
Hey jkd,

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

Zvona
07-05-2002, 09:46 AM
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, 07: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, 07:14 PM
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 ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum