We did another exercise! I did't enter to our class in ICT because I took the exam in Mapeh. We create a function called changeColor() that will be called when the user presses one of two buttons. The first button will contain the text "Press here for a yellow background". The second button will contain the text "Press here for a light green background". The function will take one parameter, a color. Its function is to change the background color of the current document.

A JavaScript function is a block of code designed to perform a particular task.
A JavaScript function is executed when "something" invokes it (calls it).
A JavaScript can be executed when an event occurs, like when a user clicks on an HTML element.
To execute code when a user clicks on an element, add JavaScript code to an HTML event attribute:
Examples of HTML events:
- When a user clicks the mouse
- When a web page has loaded
- When an image has been loaded
- When the mouse moves over an element
- When an input field is changed
- When an HTML form is submitted
- When a user strokes a key
Taken from http://www.w3schools.com/js/js_htmldom_events.asp.

0 comments:
Post a Comment