Exercise: Using clicks and branching

Write code so that when the table entry with the Z is clicked, the background colour becomes orange if it is yellow and yellow if it is orange.

Note:

Hints:

  • Use window.onload.

Solution to the exercise

Here is a possible solution to the exercise.

Note:

Hints:

  • undefined
1
2
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
td {
    background-coloryellow;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX