How to make a JavaScript function that can delete/modify text/tags from the HTML?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hrstissiaopai
    New Member
    • Mar 2013
    • 27

    How to make a JavaScript function that can delete/modify text/tags from the HTML?

    I need to make a script that can modify the already existing header tag. So in the <header> it says "Original Content" and I need to change it to "new content". I have to do that using the <button> tag and an event handler, but I have no idea what to use after the onclick. I also have another button that has to delete the text of the <header>. Is that a whole different story? Any answer will be appreciated.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I also have another button that has to delete the text of the <header>. Is that a whole different story?
    no, the only difference is that you replace the current content with empty/no content.

    what you need to look at are DOM functions (accessing and modifying HTML elements).

    Comment

    • hrstissiaopai
      New Member
      • Mar 2013
      • 27

      #3
      I know I have to user some property of the document object, but which one?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        e.g. textContent

        Comment

        Working...