发给小帖,问个小问题 那种焦点图轮换,本来是按照一定的顺序的,关键是下面这点鼠标一放到焦点上,顺序就改变了,这个,是怎么做到的分析一下这一点就好了,不用,帖源码的,谢谢~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 猜测是由setInterval()周期性调用函数实现轮播,触发onmouseover()事件时调用clearInterval()方法中断轮播,然后设置起始对象,再重新使用setInterval()执行轮播代码。 做了个小试验,发现还需要额外维持一只记录上一次鼠标位置的对象的索引号。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">body { background-color:#CCC; }table { border-collapse:collapse; margin:100px auto; }tr { height:100px; }td { width:100px; border:1px solid #FFF; }td.show { background-color:#900; }</style><script type="text/javascript">window.onload = function() { var current = 0, int, lastMouseonIndex = -1; var obj = document.getElementById('demo').getElementsByTagName('td'); for( var i = 0; i < obj.length; i ++) obj[i].onmouseover = function() { var mouseonIndex = this.parentNode.cells.length * this.parentNode.rowIndex + this.cellIndex; if (mouseonIndex != lastMouseonIndex) { int = window.clearInterval(int); current = mouseonIndex; int = window.setInterval(play, 1000); } } function play() { for (var i = 0; i < obj.length; i ++) obj[i].className = ''; current %= obj.length; obj[current].className = 'show'; current ++; } int = window.setInterval(play, 1000);}</script></head><body><table border="0" id="demo"> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr></table></body></html> javascript编写类的prototype方法时无法调用其他方法 求个正则 怎样把一个xml串的值赋给表格 blogchina 博客中的自定义的代码放在哪? 一个弱弱的问题,<tr><td>改变背景色. 怎样禁止在IE地址栏里运行javascript语句?? 在线编辑器的问题 新增多行与原来一摸一样的下拉联动列表 打开新页面的问题,好像挺简单的 新手jsp遇到情况了 求大虾帮忙 怎么用JS 实现DIV 拖动 jQuery可以使用javascript的代码吗????????????
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body { background-color:#CCC; }
table { border-collapse:collapse; margin:100px auto; }
tr { height:100px; }
td { width:100px; border:1px solid #FFF; }
td.show { background-color:#900; }
</style><script type="text/javascript">
window.onload = function() {
var current = 0, int, lastMouseonIndex = -1;
var obj = document.getElementById('demo').getElementsByTagName('td');
for( var i = 0; i < obj.length; i ++) obj[i].onmouseover = function() {
var mouseonIndex = this.parentNode.cells.length * this.parentNode.rowIndex + this.cellIndex;
if (mouseonIndex != lastMouseonIndex) {
int = window.clearInterval(int);
current = mouseonIndex;
int = window.setInterval(play, 1000);
}
}
function play() {
for (var i = 0; i < obj.length; i ++) obj[i].className = '';
current %= obj.length;
obj[current].className = 'show';
current ++;
}
int = window.setInterval(play, 1000);
}
</script>
</head><body>
<table border="0" id="demo">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>