Java Script随笔
1 2 3
| function $(id){ return typeof id === 'string' ? document.getElementById(id) : id; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13
| for (var i = 0; i < titles.length; i++) { titles[i].value = i; titles[i].onmouseover = function(){ for (var j = 0; j < titles.length; j++) { titles[j].className = ""; news[j].style.display = 'none'; } this.className = 'select'; news[this.value].style.display = 'block'; } }
|
定时器
1 2 3 4 5 6 7
| timer = setInterval(autoPlay,2000); clearInterval(timer); if (timer) { clearInterval(timer); timer = null; }
|
1 2
| timer = setTimeout(autoPlay,2000); clearTimeout(timer);
|