我刚刚完成代码,但没有显示tick.gif,而是在其上方显示了一个框“ tick”。另外,onmouseover功能也不起作用。

<!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>

最佳答案

标签的source属性在上面粘贴的代码中拼写错误。它必须是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>

关于javascript - JavaScript代码无法正常运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19625708/

10-09 19:06