PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You create a Web page that contains the following image element.

<img id=”myImage” src=”/image1.png” />

You need to write a JavaScript function that will dynamically change which image is displayed.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
function changeImage() {
myImage.src = “image2.png”;
}

B.
function changeImage() {
document.getElementById(“myImage”).src = “image2.png”;
}

C.
function changeImage() {
getElementById(“myImage”).src = “image2.png”;
}

D.
function changeImage() {
window.getElementById(“myImage”).src = “image2.png”;
}

One Comment on “Which code segment should you use?

  1. coches says:

    hello!,I really like your writing very much! proportion we keep
    in touch extra about your post on AOL? I require an expert on
    this space to unravel my problem. Maybe that’s you!
    Taking a look ahead to see you.




    0



    0

Leave a Reply