73

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

$.fn.something = function{}

3 Answers 3

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

0
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

7

See Plugins/Authoring

2
  • 2
    +1 Wow, pounced on with four similar answers. Deleting mine and upvoting the one closest to it.
    – Ken Redler
    Jun 22, 2010 at 4:19
  • 2
    Hey now, I beat him by 27 seconds ;)
    – Chad Levy
    Jun 22, 2010 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.