Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    W3C DOM way (works in IE5+/NS6+):

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

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

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks jkd

    It worked...

    Thanks a lot jkd...


  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey jkd,

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

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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";

  • #6
    Regular Coder
    Join Date
    May 2002
    Location
    Helsinki, Finland
    Posts
    231
    Thanks
    0
    Thanked 1 Time in 1 Post
    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

  • #7
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •