In your each()
loop, you can combine the object returned by data () with your default values, then merge the opts
argument with the result into a single call to $. extend () :
$.fn.plugin = function(opts) { return this.each(function() { var thisOpts = $.extend({ foo: "abc", boo: 45 }, $(this).data(), opts);
This should provide what you want: the opts
argument has the highest priority, followed by the data-
attributes of the current element, and then the default values ββfor the plugin.
source share