From http://www.w3schools.com (Copyright Refsnes Data)
| « Previous | Next Chapter » |
HTML elements can be changed using JavaScript, the HTML DOM and events.
HTML DOM and JavaScript can change the inner content and attributes of HTML elements.
The following example changes the background color of the <body> element:
Example
Try it yourself » |
The easiest way to get or modify the content of an element is by using the innerHTML property.
The following example changes the text of a <p> element:
Example
Try it yourself » |
An event handler allows you to execute code when an event occurs.
Events are generated by the browser when the user clicks an element, when the page loads, when a form is submitted, etc.
You can read more about events in the next chapter.
The following example changes the background color of the <body> element when a button is clicked:
Example
Try it yourself » |
The following example uses a function to change the text of the <p> element when a button is clicked:
Example
Try it yourself » |
The Style object of each HTML element represents its individual style.
The following example uses a function to change the style of the <body> element when a button is clicked:
Example
Try it yourself » |
The following example uses a function to change the style of the <p> element when a button is clicked:
Example
Try it yourself » |
| « Previous | Next Chapter » |
From http://www.w3schools.com (Copyright Refsnes Data)