在 jQuery 中,$.fn 有什么作用?意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3090230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 14:51:15  来源:igfitidea点击:

In jQuery, what does $.fn. mean?

jqueryjquery-plugins

提问by anthonypliu

In jQuery, what does $.fn. mean? I looked this up on google but couldn't find any concrete examples.

在 jQuery 中,$.fn 有什么作用?意思?我在谷歌上查了一下,但找不到任何具体的例子。

$.fn.something = function{}

回答by Chad Levy

It allows you to extend jQuery with your own functions.

它允许您使用自己的函数扩展 jQuery。

For example,

例如,

$.fn.something = function{}

will allow you to use

将允许您使用

$("#element").something()

$.fnis also synonymous with jQuery.fnwhich might make your Google searches easier.

$.fn也是jQuery.fn可能使您的 Google 搜索更轻松的同义词。

See jQuery Plugins/Authoring

请参阅jQuery 插件/创作

回答by Warren Rumak

This has been covered in some detail here:

此处已详细介绍了这一点:

Why jQuery do this: jQuery.fn.init.prototype = jQuery.fn?

为什么 jQuery 这样做:jQuery.fn.init.prototype = jQuery.fn?

But the short of it is that $.fnis an alias for $jQuery.prototype

但简而言之,这$.fn是一个别名$jQuery.prototype

回答by rahul