I am too curious to know the difference between $ and $.fn? Can anyone please explain this to me in details? Also what is $.fn?
I am too curious to know the difference between $ and $.fn ? Can
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$is a function (specifically, a variable pointing to thejQueryfunction — an alias).$.fnis a property on that function, which points to the prototype of the internalinitfunction jQuery uses to create instances, as we can see in the jQuery code:(That’s line 289 of the current un-minified jQuery file, v1.8.3.)
$.fnis there so that it’s easy to add properties to it. When you create jQuery objects, they have those properties, because of JavaScript’s prototypical inheritance. The most common properties to add to it are, of course, functions that do things (jQuery plug-ins).