gpt4 book ai didi

javascript - Jquery函数模板和方法模板有什么区别

转载 作者:行者123 更新时间:2023-12-03 08:00:47 25 4
gpt4 key购买 nike

我不清楚Jquery函数模板和方法模板之间以及如何使用它们。以下是函数模板和方法模板的片段,但它们之间有什么基本区别。

函数模板:-

(function($){
$.fn.myFirstPlugin = function(settings){

};
})(jQuery);

方法模板:-

(function($){
$.myPlugin = function(settings){

};
})(jQuery);

最佳答案

Function Template

定义选择器的方法,例如; $("html").myFirstPlugin() 其中 this : "html" ,选择器

Method Template

将函数定义为 jQuery 对象的属性,例如; $.myPlugin() 其中 this : jQuery ,除非设置为不同的上下文

关于javascript - Jquery函数模板和方法模板有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34586519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com