【发布时间】:2015-07-05 08:08:43
【问题描述】:
Onmouseover(在图像上)我正在清除 setInterval 函数。 Onmouseout 我需要重用相同的 setInterval 函数。但是由于它在鼠标悬停事件期间被清除,因此它不适用于鼠标悬停。如何再次使用 setinterval 函数 onmouseout?
我正在尝试创建一个幻灯片小部件(类似于 YAHOO HOMEPAGE 中的东西)。
p = 0;
function list(event) {
var x = event.target || event.srcElement;
document.getElementById("outer").src = x.src;
x.style.borderBottom = "thick solid #0000FF";
allimg[0].getElementsByTagName('img')[g].style.borderBottom = "none";
clearInterval(cha); //clearing autoincrement of images onmouseover
clearInterval(rcli); //clearing autoright click button onmouseover
clearInterval(chanid); //??? CLEARING HERE
x.addEventListener('mouseout', function () {
x.style.borderBottom = "none";
function chan() {
allimg = document.getElementsByClassName("container"); //container within which all images are there
u = allimg[0].getElementsByTagName('img');
for (p; p < u.length; p++) {
if (u[p].style.borderBottomStyle == "solid" || u[p] == x) {
a = p;
u[a].style.borderBottom = "none";
a++;
document.getElementById("outer").src = u[a].src;
u[a].style.borderBottom = "thick solid #0000FF";
break;
}
}
p++;
}
chanid = setInterval(chan, 2000);
});
}
【问题讨论】:
-
能贴一下相关代码吗?
-
你可以想象我正在尝试在雅虎主页中创建什么。我无法粘贴所有 HTML 代码,因为一切都很长。这是特定的 JS 代码,我在这里感到震惊
标签: javascript