Web Analytics Made Easy -
StatCounter How do I delete an object in DHTML ??? - CodingForum

Announcement

Collapse
No announcement yet.

How do I delete an object in DHTML ???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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

    Comment


    • #3
      Thanks jkd

      It worked...

      Thanks a lot jkd...

      Comment


      • #4
        Hey jkd,

        what does this do?
        document.getElementById("elemName").style.display="none";
        Scripting | JavaScripts | PerlScripts | Python Scripts | Articles | My Journal

        Comment


        • #5
          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";
          Glenn
          vBulletin Mods That Rock!

          Comment


          • #6
            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 :
            Zvona
            First Aid for
            Web Design

            Comment


            • #7
              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

              Comment


              • #8
                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

                Comment

                Working...
                X