Why we use this Jquery(document).ready()
instead $(document).ready()
Actually this both are giving same result, but what the reason for using one of the, normally lost of people are using $(document).ready()
instead above listed
Why we use this Jquery(document).ready()
instead $(document).ready()
Actually this both are giving same result, but what the reason for using one of the, normally lost of people are using $(document).ready()
instead above listed
this is usually to avoid conflict with other libraries that could be using the "$" sign.
Well you may have more JavaScript libraries than only jQuery, and some of them may use the dollar sign $
too. If you use jQuery
instead, you have more guaranted, that in this variable will be jQuery instance.
This is to prevent namespace collision. The dollar sign might be used by other JavaScript libraries. For this jQuery also provides the jquery.noConflict()
function.
$ and jQuery both point to the window.jQuery object, so they are one and the same. the reason some scripts use jQuery instead of $ is to prevent conflicts with other libraries such as prototype or different versions of jquery which both also use the $ variable.
to get full compatibility. For example in Wordpress CMS, jquery is built in, but not using $. so it's safer to create plugins using jQuery(function($){});. Take note that $ added as a parameter so that you can use it inside the ready.