如何编写一个jquery插件,带传入函数的功能

2025-04-13 14:04:59
推荐回答(1个)
回答1:

(function() {
$.fn.TestPlugin = function(){

var options = arguments;

var method = args[0];

var args = Array.prototype.slice.call(options, 1);

method.apply($(this),args);


var methods = {

setWidth: function(width) {
$(this).width(width)

}
}

})()

调用:


$(".testClass").TestPlugin("setWidth", "100")