jQuery Syntax

The jQuery syntax is tailor-made for selecting HTML elements and performing some action on the element(s).
Basic syntax is: $(selector).action()
1) A $ sign to define/access jQuery
2) A (selector) to “query (or find)” HTML elements
3) A jQuery action() to be performed on the element(s)

$(this).hide() – hides the current element.
$(“p”).hide() – hides all <p> elements.
$(“.test”).hide() – hides all elements with class=”test”.
$(“#test”).hide() – hides the element with id=”test”.

$ is just a shortcut for jQuery. The idea is that everything is done with the one global symbol (since the global namespaces is ridiculously crowded), jQuery, but you can use $ (because it’s shorter) if you like.

// These are the same barring your using noConflict (more below)
var divs = $(“div”); // Find all divs
var divs = jQuery(“div”); // Also find all divs, because
console.log($ === jQuery); // “true”