This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 传统的方法 | |
window.onload=function(){ | |
var tab=document.getElementById("tab"); | |
var a=tab.getElementsByTagName("a"); | |
var div=tab.getElementsByTagName("div"); | |
for(var i=0;i<a.length;i++){ | |
a[i].index=i; | |
a[i].onmouseover=function(){ | |
for(var j=0;j<a.length;j++){ | |
a[j].className=""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload=function(){ | |
var oBtn=document.getElementsByTagName("button")[0]; | |
oBtn.onclick=function(){ | |
changeLineColor(document.getElementById("num").value); | |
} | |
changeLineColor(); | |
}; | |
function changeLineColor(num){ | |
var n=Number(num)>0 && Number(num)<6?Number(num):2; | |
var colors=["yellow","red","blue","green","grey"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload=function(){ | |
//获取页面元素 | |
var aBtn=document.getElementsByTagName("button"); | |
var box=document.getElementById("box"); | |
var tip=document.getElementById("tips"); | |
//定义三个函数,用三种方式循环改变背景颜色 | |
var fn=[function(){ | |
//第一种,遍历取出数组中的颜色值 | |
var colors=['yellow','red','black','blue','green']; | |
var i=0; |
NewerOlder