Question: Fun With JavaScript Use JavaScript to change the title when the user clicks on a button. There is a button on the webpage with the

Fun With JavaScript

Use JavaScript to change the title when the user clicks on a button. There is a button on the webpage with the text Change Title. Add tags to the head section of the HTML document. Then create a function called changeTitle:

function changeTitle() { document.title = ; }

Inside the quotation marks, add some text for a title. When you click on the button, the title of the webpage should change from JavaScript is so cool. to the title you added.

Using the element, add an image to the page below the button. Download or use two images; they can be whatever you want. Have the img element display the first image. You will add an onmouseover event to show the second image when the mouse is over the image.

Create a JavaScript function below the changeTitle function and call it changeImage1. Add this line to the function:

document.getElementsByTagName(img)[0].setAttribute(src, yourimagenamehere.jpg);

Replace yourimagenamehere.jpg with the name of the second image. Add the following attribute to the img element:

onmouseover="changeImage1();"

To go back to the first image, create a function called changeImage2, copy the line from changeImage1, and change the name of the image to the first image.

Under the image, add a paragraph element with the text Change Me inside the element. Add an id attribute called myparagraph. We will add an event handler that will activate when the text is clicked.

Add a JavaScript function called changeMe() Add the following line:

document.getElementById('myparagraph').innerHTML = "Changed!";

This line gets the attribute by its id (which should be unique so the method returns only one element and you dont have to use an index to get it) and changes the text inside the element.

Add the event handler to the paragraph element:

onmousedown = changeMe();

Now click on the text. It should change.

Add an h2 element to the page under the paragraph with the text Change Background Color and an id called myh2. Add a style element to the head section of the document and add a background color for the h2 element.

Add a JavaScript function called changeColor() with the following line:

document.getElementById('myh2').style.backgroundColor="green";

You can change the color of blue to any color youd like.

Add the onmouseover event handler to the h2 element that calls the changeColor function.

It is a javascript assignment. You can put any image on it. Please help me thank You.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!