Search code examples
javascripthtmlimageonmouseoveronmouseout

Javascript code not running properly


i just finished my code but instead of showing tick.gif it shows the word "tick" with a box over it. Also the onmouseover feature isn't working either.

<!DOCTYPE html>
<html>
<head>
<title>Changeup test</title>
</head>
<body>
<img scr="tick.gif" alt="tick" onmouseover="this.scr='tick2.gif';
"onmouseout="this.gif='tick.gif';" />
</body>
</html>

Solution

  • The source attribute for the tag is misspelled in the code you pasted above. It needs to be src.

    <!DOCTYPE html>
    <html>
      <head>
      <title>Changeup test</title>
      </head>
      <body>
        <img src="tick.gif" alt="tick" onmouseover="this.src='tick2.gif'; "onmouseout="this.src='tick.gif';" />
      </body>
    </html>