在下面的代码中,如何thebody
同时app.body
成为 JQuery 对象,但将.css
属性设置为thebody
有效但无效app.body
?
var app = app || {};
app.show = function(html) {
this.baseElement.html(html);
};
app.body = $('body');
app.init = function() {
this.baseElement = $('div#app');
var thebody = $('body');
console.log(app.objectIsJquery(thebody)); //true
console.log(app.objectIsJquery(app.body)); //true
app.body.css('background-color', 'yellow'); //does not set the background color, no errors
//thebody.css('background-color', 'yellow'); //sets color correctly
};
app.start = function() {
this.baseElement.css('color', 'brown');
this.show(dp.qstr.addStar('testing'));
};
app.objectIsJquery = function(obj) {
return obj.selector != undefined;
}