Overwrite default properties in jQuery plugin

can someone explain overwriting the default properties and even extending them with jQuery inside my plugin example, as well as the close function

$.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"}); 
+4
source share
1 answer

You can use jQuery extend to overwrite the default options:

 var options = $.extend({}, defaults, options); 

See also:

+8
source

Source: https://habr.com/ru/post/1333626/


All Articles