好的,我应该改变标题。如果悬停在整个页面上,它会起作用,但是如果我将悬停仅放在div上,则它不起作用。
身体内部:
<div id="gallery">
<img src="slides/BarbedWire.jpg" alt="Barbed Wire" />
<img src="slides/Feather.jpg" alt="Feather" />
</div>
在脚本中。这个工作:
function startSlider() {loop=setInterval ( moveRight, 1000 )}
startSlider();
function stopLoop(){
window.clearInterval(loop)}
onmouseover = stopLoop;
onmouseout = startSlider;
这不起作用:
function startSlider() {loop=setInterval ( moveRight, 1000 )}
startSlider();
function stopLoop(){
window.clearInterval(loop)}
gallery = document.getElementById('gallery');
gallery.onmouseover = stopLoop;
gallery.onmouseout = startSlider;