jquerylike wrap

 1 function $(selector){
 2  return new O(document.getElementById(selector));
 3 }
 4 function O(ele){
 5  this.ele=ele;
 6 }
 7 O.prototype.show=function(){
 8  this.ele.style.display='';
 9  return this;
10 };
11 O.prototype.hide=function(){
12  this.ele.style.display='none';
13  return this;
14 };
15 $('#id').show().hide();

 

posted @ 2014-11-06 10:32  rocky2  阅读(98)  评论(0)    收藏  举报