Berto A.

asked • 04/22/21

Javascript wont load image

I have a button with onclick = "generateCat()" in my html file. When I click the button running a web browser the image will not load.


function generateCat(){

    var image = document.createElement("img");// Create image element

    var div = document.getElementById("flex-cat-gen"); // Get access to div container

    image.src = "image\320464.jpg";

    div.appendChild(image); // To the div appendchild (image)

}



1 Expert Answer

By:

Jack B. answered • 04/28/21

Tutor
5.0 (90)

I teach HTML, CSS, JavaScript, and anything related to Computer

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.