<! DOCTYPE HTML > < HTML lang = "EN" > < head > < Meta charset = "UTF-. 8" > < title > lamp switch </ title > </ head > < body > <-! Introducing two images -> < IMG ID = "ON" the src = "IMG / on.gif" > < Script > // 1. acquired two images of objects var ON = Document.getElementById("on"); // 2. Define a determination variable var Fun = to true ; // 3. Binding Events on.onclick = function () { IF (Fun) { on.src = " IMG / on.gif " ; Fun = to false ; } the else { on.src = " IMG / off.gif " ; Fun = to true ; } } function F (Fun) { } </script> </body> </html>