|
- Decide on three world cities you love, and find beautiful images to represent each. Save the URL for each image in a notepad.
- Create an HTML Page with 3 buttons on top. Name each button after a city, and clicking each button should run a function corresponding to that city.
Make sure each button has an id and an onClick attribute
- Add a text element (use <p> or <div>). This is the label where you are going to put the city name.
Make sure it also has an id attribute and remember to add a close tag. (</p> or </div>).
- Under the text label, add ONE image element <img> with the source attribute empty (src=" ")
This is where the city image will go after you click one of the buttons. Make sure it also has an id attribute (like id="cityImage")
- Next, go into the < script> section of your code and write the function for your first city.
<script>
function doMilan() {
//what the function does goes here
}
</script>
- Add code to the fuction to do the following: when the button is clicked, change the src=" " of the image element to have URL for the image for that city.
So something like:
document.getElementById("cityImage").src = "yourOwnPhotoOfMilan.jpg";
- Now, do the same to the .innerHTML=" " of the text label, change it to be the name of the city.
- Also inside the function, change the background color and font of the page to be specific to that city.
- Repeat for the other two cities by copying the 1st city function and editing.
- FOR EXTRA CREDIT: Show the local time (HH:MM) in that city. Hint: use var dateTime = new Date ();
|
|