What does the jQuery() function in jQuery do?

后端 未结 4 612
臣服心动
臣服心动 2021-01-25 08:06

In this video there is a snippet of code that goes something like this:

if (jQuery) {jQuery(function() {
    // ...
})}

I\'ve never seen the

4条回答
  •  [愿得一人]
    2021-01-25 08:39

    jQuery(function()
    

    is same as

    $(document).ready(function()
    
    if(jQuery)
    

    is a check whether the jQuery.js file has been loaded or not.

    There is another way to check this

    if (typeof jQuery == 'undefined')
    {
        //jQuery has not been loaded  
    }
    

提交回复
热议问题