73

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

$.fn.something = function{}
anthonypliu
  • 12,179
  • 28
  • 92
  • 154

3 Answers3

133

It allows you to extend jQuery with your own functions.

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.

See jQuery Plugins/Authoring

Derlin
  • 9,572
  • 2
  • 32
  • 53
Chad Levy
  • 10,032
  • 7
  • 41
  • 69
9

This has been covered in some detail here:

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

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

Community
  • 1
  • 1
Warren Rumak
  • 3,824
  • 22
  • 30
7

See Plugins/Authoring

rahul
  • 184,426
  • 49
  • 232
  • 263