<div class="odiv">点击</div>
<script>
var Obj = {
//初始化数据
Fn :function(){
this.num = 111,
this.odiv = document.getElementsByClassName('odiv')[0];
this.bindEvent()
//bindEvent(element, eventName, func) —— 绑定func到element的eventName事件上(不重复绑定)
//unBindEvent(element, eventName, func) —— 删除element上的eventName事件上的func函数。
(这里只是定义的一个对象函数,具体可以看文档的说明)
},
//绑定事件
bindEvent : function(){
this.odiv.onclick = $.proxy(this.show,this)
},
//事件处理函数
show : function(){
console.log(this.dispose(this.num));
},
//num的处理函数
dispose : function(num){
return num + 111;
}
}
Obj.Fn()
</script>