jQuery - Basics and Syntaxes

In the tutorial on jQuery - Basics and Syntaxes, we will learn jQuery's Document Ready Event, jQuery Selectors, and jQuery Methods. Their usage and syntaxes.
Submitted by Pratishtha Saxena, on September 01, 2022

Document Ready Event

This is the very first command that is to be executed. This makes sure that the document, on which we are working on, gets completely loaded before any further manipulations. As we don’t want that all the elements, images, videos, etc. on the DOM are not loaded. Everything after this goes into the function present there.

Syntax:

$(document).ready(function(){
  // jQuery Code
});

Now, while working with jQuery, you'll come across the dollar sign ($) a lot. It lets you access jQuery. This sign indicates that the command following is written in jQuery.

jQuery Selectors

Using jQuery, HTML elements can be selected and different operations and changes can be performed on it. These elements are selected with the help of 'selectors'. The selector can be the tag name, id, class, etc. Once the HTML element is selected then the required action can be performed.

Syntax:

$('selector').method();

jQuery Methods

These are the predefined actions that can be performed on an HTML element. jQuery already have various method that makes the code very optimized and efficient and reduces mess. These methods in some cases are also called events. Some of the methods take in various parameters also termed attributes. A function can also be declared in a method.

Syntax:

$('selector').method(function(){});



All jQuery Examples

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.