jQuery vs Dollar Sign

When developing with JQuery, we have the option of using the standard JQuery function or the short version ($ sign). But which one is better to use?

Let’s look at some example code.

jQuery(document).ready(function()
{
    jQuery(".p.hide").hide()
});

What’s happening here is, JQuery is ready to be used and abused when the DOM has been fully loaded. We use the jQuery function to reference the JQuery software we have included in our page, but to save time, the dollar sign could be used instead.

So the above code could be made a tad smaller.

$(document).ready(function()
{
    $(".p.hide").hide()
});

Leave a Reply