Javascript 使用innerHTML将鼠标移到图像上
当鼠标移过图像时,我需要将其调出。我相信它也应该使用innerHTMLJavascript 使用innerHTML将鼠标移到图像上,javascript,jquery,html,image,mouseover,Javascript,Jquery,Html,Image,Mouseover,当鼠标移过图像时,我需要将其调出。我相信它也应该使用innerHTML <body> <a href="#">anime</a> <a href="#">ponies</a> <h1 class="panel">What fandom is better?</h1> <div class="anime"> <img src="img/anime.png"> </div> &l
<body>
<a href="#">anime</a>
<a href="#">ponies</a>
<h1 class="panel">What fandom is better?</h1>
<div class="anime"> <img src="img/anime.png"> </div>
<div class="pony"> <img src="img/pony.png"> </div>
<p id="answer">Choose One</p>
</body>
/**
This is for element changes upon mousesing over of the area
*/`
document.getElementsByClassName("anime")[0].onmouseover=
function(){
orangeBorder1();
mouseAnime();
}
document.getElementsByClassName("pony")[0].onmouseover=
function(){
orangeBorder();
mousePony();
}
function mousePony(){
document.getElementById("pony").src="pony1.png";
}
我不知道你的代码是否被复制错了,但你没有任何带有小马id的东西 getElementById将查找具有id属性的标记,并指定该属性,您的代码将正常工作
id在页面中应该是唯一的。您还应该给div一个id,而不是查询类名您没有任何id小马,因此它不会抓取任何东西。您应该将id小马添加到img标记中,它应该可以工作。带有id小马的代码段是以前尝试使用id更改图像时留下的。它不起作用,我删除了ID,但忘记删除脚本中对ID的引用。由于CSS错误和图像链接错误,它无法正常工作。