网页特效6--End

加了个班,到今天为止,结束网页特效的学习。截个图纪念一下:

 迷糊着写下了一段满意的代码:

    -----------------------------------------------------------------------------------
<script>
// prototype属性使您有能力向对象添加属性和方法
// this用来构造函数:普通函数使用了this变量,生成实例(对象)
// new:让this指向新的对象

// 获取对象
function List(id){
this.id=document.getElementById(id);
this.lis=this.id.children[0].children; //Bug:不要漏了id
}

// init初始化
List.prototype.init=function(){
var that=this;
for(var i=0;i<this.lis.length;i++){
this.lis[i].onmouseover=function(){
that.show(this.children[0]);
}
this.lis[i].onmouseout=function(){
that.hide(this.children[0]);
}
}
}

// 显示模块
List.prototype.show=function(obj){
obj.style.display="block";
}
// 隐藏模块
List.prototype.hide=function(obj){
obj.style.display="none";
}

// 调用:通过new 实例化了一个对象 叫 list
var list=new List("list");
list.init();

</script>
-----------------------------------------------------------------------------------
明天开始进击愤怒的JQuery[]~( ̄▽ ̄)~* 又到了凌晨1点半,晚安世界。
裸辞自学转前端的准程序媛。 谨以此博献给那些勤[暗]勉[无]刻[天]苦[日]的自学时光。 博客园:慕女神 || 知乎:慕小慕 || QQ:1042919536 共勉
原文地址:https://www.cnblogs.com/xiaomu2017/p/6440807.html