模拟JQUERY的延迟方法绑定,
对于延迟方法绑定,各种语言都有不同的描述
什么回调啊,函数指针啊,委托啊,事件啊等,其实也就是那么大回事,不过用好这些特性,对于扩展和架构是非常有好处的,
好处自然就不说啦,下面的这些代码仅供把玩,BUG和不兼容是有的,每次放列子,都有伙计叫我写完
我想说,写完了,我还会在这里写博客么,不如泡妹子
<script type="text/javascript"> $('t').click(function() { alert('111'); }); function $(e){ return new jq(e); } function jq(e) { this.s = document.getElementById(e); this.click = function(c) { this.s.onclick = c; }; this.change = function(c) { }; this.val = function() { return this.s.value; } } </script>