Modifying element content

Objective

  • Select and modify the content of a specific element

element.innerHTML property

  • You can modify the content of an element using its .innerHTML property
  • See onclick4.html for an example of using element.innerHTML
  • See onclick5.html for an example of using element.innerHTML with a timer
  • There are more sophisticated ways of modifying the content of a page using the DOM. You can create nodes, set attributes, and add and remove nodes as needed. That will be covered later in the course.