www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to delete text inserted with innerHTML

  1. #1
    Join Date
    Jul 2008
    Posts
    83

    How to delete text inserted with innerHTML

    Hi All developers.
    I'm trying to find out how can i delete some text inserted with the (innerHTML) DOM construct, the simple div i've designed its empty, and after an event handler call the function some text appears...like so
    //code
    function write(){
    document.getElementById('somediv').innerHTML= "hey man whats up?";
    }
    //eof code

    what i would like to create its a function that deletes that text.
    anyway i would call the function through an event handler like so:

    <a href="#" onMouseover="write()" onMousedown="delete()">blablabla</a>

    Thank you guys for any help

  2. #2
    Join Date
    Dec 2008
    Location
    Didim, Turkey
    Posts
    105
    Hi, Maybe try this:

    Code:
    function delete(){
    document.getElementById('somediv').innerHTML= "";
    }
    Mike

  3. #3
    Join Date
    Nov 2008
    Location
    Akron, OH
    Posts
    233
    push it a bit farther ....
    wrap the fx in a setTimeout() to make the text 'disappear' after a set time.
    eg

    .
    .
    .
    .
    .
    function delete(){
    document.getElementById('somediv').innerHTML= "";
    }
    </script>
    </head>

    <body onload="setTimeout(delete(), 5000)">
    .
    .
    .
    .

    second param is millisec
    javawebdog
    Two things to remember:
    "The only place success comes before work is in the dictionary."
    "It's more than just a matter of survival. It's a matter of sympathy, compassion, passion and style."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles