(function (window, undefined) {
var document = window.document,
$ = function (id) {
return $.fn.init(id);
}
$.fn = $.prototype = {
init: function (id) {
this.selector = document.getElementById(id) || id;
return this;
},
alerttxt: function () {
var selector = this.selector;
return selector.innerHTML;
},
addid: function () {
var txt = this.selector;
alert(txt+"你好");
}
}
$.fn.init.prototype = $.fn;
window.$ = $;
})(window);
因为
alerttxt: function () {
var selector = this.selector;
//这里return的不对
return selector.innerHTML;
}