有人可以解释覆盖默认属性,甚至在我的插件示例中使用jQuery扩展它们以及闭包函数
$.fn.myObject = function(overwriteProperties) {
var properties = {myproperty1: "defaultvalue"}
// overwrite properties here
function doStuffHere() {
}
return (function() {
return this; // does this part here refer to the object of myDiv
});
}
$('#myDiv').myObject({myPoperty1:"newValue"});
Run Code Online (Sandbox Code Playgroud)
您可以使用jQuery extend来覆盖默认选项:
var options = $.extend({}, defaults, options);
Run Code Online (Sandbox Code Playgroud)
另见:
| 归档时间: |
|
| 查看次数: |
1080 次 |
| 最近记录: |