Learn javascript and html buttons

In this example we change the content of a <h2>-tag using two buttons. document.getElementById("TheIDofTheTag"); gets us an object pointer to the h2-tag and we use the object method innerHTML to change the tag. The button calls a function called write_text_to_html_tag via onclick. The function write_text_to_html_tag is declared in the header of this tutorial page.

This is the h2-tag and by pressing the buttons below you can change the text

Just click view page source in your browser to see the source code and understand how it works.

Written by Guido Socher, License: free, take it and do whatever you want.