0

I've found this function and I'm not sure about what's doing

(function($) {
    $(document).ready(function() {
        /
        $('.auto-scroll').off('click').on('click', function(event) {
            event.preventDefault();
            ....
            ....
        });

        $("#btnBuscar").on("click", function() {
            ...
            ...
        });
    });

})(jQuery);

What is the meaning of pass JQuery as a parameter?

Krupesh Kotecha
  • 2,396
  • 3
  • 21
  • 40
afsdi3
  • 37
  • 1
  • 6

1 Answers1

0

What is the meaning of pass JQuery as a parameter?

It's passing jQuery as an argument, and receiving it as the $ parameter. That way, within the anonymous function, it can use $ when using jQuery, rather than having to use jQuery. This is useful when you can't be sure that the global $ is already equal to jQuery (which it may not be, if a page has used noConflict to release it).

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875