Javascript innerHTML

Using Javascript, you can change the content of a certain tag just through basic javascript browser functions. This can be useful for navigation systems, content on a page to display, etc.

Here is an example:

[code lang=”html”]

[/code]

This is a basic javascript function to set the innerHTML of one id to the innerHTML of another. Now lets make the html in the body of the page.

[code lang=”html”]

Click here to change the content!

Content #1.

[/code]

When you click the link the content will change to #2.

Here is a good example for using navigation bars:

[code lang=”html”]

Link 1 | Link 2 | Link 3

Navigation details displayed here…

[/code]

You can view a live working version of these here!

Filed under: Web Programming

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *
Website