Skip to content

Instantly share code, notes, and snippets.

View ioslh's full-sized avatar
😀

Lianghua ioslh

😀
View GitHub Profile
// 传统的方法
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="";
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"];
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;