Introduction to jQuery syntax

It is used to select elements in the HTML and perform actions on those elements.

The syntax is as follows:

$(selector).action()

$ symbol: It grants access to jQuery.

(Selector): This is used to find HTML elements.

jQuery action(): Used to perform operations on the element.

  1. Used to hide the current element.$(this).hide()
  2. Used to hide all < p> elements.$(“p”).hide()
  3. Used to hide all elements with class=”test”.$(“.test”).hide()
  4. Used to hide id=”test” element.$(“#test”).hide()

File Ready Events:

The jQuery method is located in the Document ready event and makes it easy to read the code. $(document).ready(function(){// jQuery method}); This is to check and stop jquery before finishing loading the document. This method also allows you to include JavaScript code at the beginning of the body of the document.

If the method is run before the loaded document, some operations may fail:

Gets image dimensions that haven’t been loaded yet, or hides image elements that haven’t been created yet.

Shorter ways to prepare documents: $(function(){// jQuery Method});