大神求教,直接写的一个仿造jquery的框架,求指教如何给click 处添加事件绑定
(function(){
window._$ = window.$; var BB = window.BB = window.$ = function(selector){ return new BB.fn.init(selector); }
BB.fn = BB.prototype = {
init : function(selector){
if(selector){
this.selector = selector;
if(this.selector && this.selector.indexOf('#') == 0 && this.selector.length != 1){
var id = this.selector.substring(1);
var obj = document.getElementById(id); this.obj = obj;
} }
return this; },
val : function(newValue){
debugger;
var obj = this.obj;
if(obj){ var type = obj.nodeName;
if(newValue == undefined){
return "INPUT" == type ?obj.value : obj.innerHTML;
} else {
if("INPUT" == type){ obj.value = newValue; } else{ obj.innerHTML = newValue; } } } }
};
cilck: function(fn){
var obj = this.obj;
//添加一个单击事件
}
BB.fn.init.prototype = BB.fn;})();
( function($) {
//alert(obj.fn);
$.noConflict = function() {
window.$ = window._$;// 把$还给在开始处取得的引用.
};
})(BB);
(function($){
//alert(obj.fn);
$.noConflict = function(){
window.$ = window._$;//把$还给在开始处取得的引用.
}
});
(function(){
window._$ = window.$; var BB = window.BB = window.$ = function(selector){ return new BB.fn.init(selector); }
BB.fn = BB.prototype = {
init : function(selector){
if(selector){
this.selector = selector;
if(this.selector && this.selector.indexOf('#') == 0 && this.selector.length != 1){
var id = this.selector.substring(1);
var obj = document.getElementById(id); this.obj = obj;
} }
return this; },
val : function(newValue){
debugger;
var obj = this.obj;
if(obj){ var type = obj.nodeName;
if(newValue == undefined){
return "INPUT" == type ?obj.value : obj.innerHTML;
} else {
if("INPUT" == type){ obj.value = newValue; } else{ obj.innerHTML = newValue; } } } }
};
cilck: function(fn){
var obj = this.obj;
//添加一个单击事件
}
BB.fn.init.prototype = BB.fn;})();
( function($) {
//alert(obj.fn);
$.noConflict = function() {
window.$ = window._$;// 把$还给在开始处取得的引用.
};
})(BB);
(function($){
//alert(obj.fn);
$.noConflict = function(){
window.$ = window._$;//把$还给在开始处取得的引用.
}
});

