在 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
In jQuery, what does $.fn. mean?
提问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()
$.fn
is also synonymous with jQuery.fn
which might make your Google searches easier.
$.fn
也是jQuery.fn
可能使您的 Google 搜索更轻松的同义词。
请参阅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 $.fn
is an alias for $jQuery.prototype
但简而言之,这$.fn
是一个别名$jQuery.prototype