Table of Contents
What you should know before learning jquery
You will need basic knowledge before learning jQuery:
If you want to study the above subject is available on the homepage of our website
What is jQuery?
jQuery is very easy to learn, it is also easy to write and includes a JavaScript library.
jQuery is meant to be used On your website and it belongs to JavaScript.
jQuery performs many functions and also requires JavaScript code. jQuery call us single line code.
jQuery offers us several features, some of which are as follows:
- Animations and Effects
- HTML event methods
- CSS manipulation
- HTML/DOM manipulation
- AJAX
jQuery has plugins for almost any function.
Why jQuery use?
JavaScript has a lot of libraries, but jQuery is probably the most popular and also the most extensive.
jQuery is used by many large companies on the web, such as:
- Netflix
- IBM
- Microsoft
Also uses the company jury shown above and that is why jQuery is so famous it is very easy to use that is why it is very easy to use jQuery instead of JavaScript.
jQuery Syntax
The composition of sentences in jQuery corresponds to the selection and action of HTML elements.
Basic Syntax of jQuery is: $(selector).action()
- A $ sign to define/access jQuery
- A (selector) to “query” or find HTML elements
- A jQuery’s action() method to be performed on the elements
Examples:-
$(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”.
jQuery’s Document Ready Event
You may have noticed that all of the jQuery methods from the examples shown above are within the document ready event:
$(document).ready(function(){
// jQuery methods go here...
});
It prevents any jQuery code from running the document. ready event before the document is finished loading.
This also allows you to take the JavaScript code before the main body of your document in the main document. It is a good practice to wait for the document to be fully loaded and ready before working with it.
The above are just a few examples of actions that can cause the documents to load completely and if the methods have been used before or are used as follows:
- Trying to hide an element that is not created yet
- Trying to get the size of an image that is not loaded yet