次のコードでは、どのよう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;
}