(function ($) {
...
} ) (jQuery);
To avoid conflicts with other javascript libraries that also use $.
This method, however, allows you to use $ in that function at your will, no need to use jQuery there.
That pattern is also important when writing jquery plugins.
It creates a function, with $ as an argument, and immediately runs that function with jQuery as the argument. Effectively this will ensure that $ points to jQuery inside your code, even if jQuery.noConflict() is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With