: 的jQuery 1.3.2 jQuery UI的1.7.2的jQuery插件幫助
我發現下面的jQuery的片段,但我與它有問題。
$(document).ready(function() {
$.widget("ui.hello", {
options: {
foo: "bar",
baz: "quux"
},
_init: function() {
var text = this.options.text;
this.element.innerHTML("hello " + this.options.foo + " and " + this.options.baz);
}
});
$("#thing").hello({ foo: "WORLD!" });
});
這裏的問題:
this.options.baz); 未定義不應該使用默認值嗎?
來源: http://blog.citrusbyte.com/2010/09/16/jquery-widgets-bringing-sanity/