How does jQuery have the $ object constructor and the methods associated with the $?

后端 未结 4 1669
你的背包
你的背包 2021-02-01 09:54

How is it that jQuery can do $(\"#foo\").addClass(\"bar\") and $.ajax()?

I\'m creating a micro javascript framework and want to create a new in

4条回答
  •  情书的邮戳
    2021-02-01 10:32

    Two different things:

    $.ajax is a prototyped function of jQuery called ajax.

    While $('foo') is a call of the jQuery function and depending on the type of foo it reacts in different ways. At http://api.jquery.com/jQuery you can see that jQuery (almost the same as $) can react on three different types: selectors, html or callbacks.

提交回复
热议问题