Menu

Hi Trying Write Javascript Code Click Image Called Smileyfacepng Message Alert Clicked Sma Q43792535

Hi,

I am trying to write a javascript code so that when I click onthe image called smileyFace.png the message alert “you clicked onthe smaileyFace picture” is displayed.

My code is below. It does not work. Could you please keep it assimple as possible and use <div> tags, onclick andgetElementById

Please keep it simple as I am new to javascript

Thank you

<html>
<body>

<img id=”exampleImage” src=”smileyFace.png” />

<button onclick=”myFunction()”>Try it</button>

<script>
          document.getElementById(“exampleImage”).innerHTML
          onclick=”display()”;
          
           functiondisplay() {
           alert(“youclicked on the smileyFace picture”);
           }
</script>

</body>
</html>

Expert Answer


Answer to Hi, I am trying to write a javascript code so that when I click on the image called smileyFace.png the message alert “yo…

OR