What is the difference between these two word in jQuery

戏子无情 提交于 2019-12-23 18:11:45

问题


I am trying to get the version of jQuery a page is using in an alert. It works perfect:

I use alert(jQuery.prototype.jquery)

Now my question is what is the difference between jQuery and jquery words here that are specified before and after prototype.

which one is specified by $.


回答1:


The global $ and jQuery variables just point to the same function object, they are "aliases". jquery is just the name of the property of the prototype object. The two names have nothing to do with each other - they are names of different properties on different objects.




回答2:


The first is specified by "$", the second is meant to return the jquery version number.

In Chrome console ->

jQuery >>> function (a,b){return new e.fn.init(a,b,h)}

$ >>> function (a,b){return new e.fn.init(a,b,h)}

jQuery.prototype.jquery >>> "1.7.1"

Perhaps it would help to note that JavaScript is case sensitive, so jQuery and jquery are two different variables.




回答3:


The $ is the same as jQuery with a capital 'Q'. The lowercase jquery only represents the version number.

It is more commonly written as jQuery.fn.jquery or as a property of a constructed jQuery object like jQuery('div').jquery.



来源:https://stackoverflow.com/questions/12202717/what-is-the-difference-between-these-two-word-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!