What is jQuery?
jQuery is a fast, functional, multi-functional JavaScript library created by John Resig in 2006 with a meaningful motto: Write less, do more - Write less, do more .
jQuery simplifies HTML document browsing, event handling, animation and Ajax interaction for fast web development. Web analytics has shown that jQuery is the most widely deployed JavaScript library.
jQuery is a set of JavaScript tools designed to simplify different tasks by writing less code. The following lists some of the most important features supported by jQuery:
- Manipulating the DOM - jQuery makes it easy to select DOM elements to traverse (browse) as easily as using CSS, and edit their content by using the open source Selector media, which is called Sizzle .
- Event handling - jQuery helps to interact with users better by handling diverse events without making HTML code messy with Event Handler.
- AJAX support - jQuery helps you a lot to develop a feature-rich and responsive site using AJAX technology.
- Animated effects - jQuery comes with a lot of beautiful animation effects that you can use for your websites.
- Compact - jQuery is a lightweight library - it is only about 19KB (gzipped).
- Most supported by modern browsers - jQuery is supported mostly by modern browsers, and works well on IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+.
- Update and support the latest technologies - jQuery supports CSS3 Selector and basic XPath syntax.
How to use jQuery?
There are two ways to use jQuery:
Local installation - You can download the jQuery Library on your computer and include it in the HTML code.
Using from CDN (CDN Based Version) - You can put jQuery library into HTML code directly from the Content Delivery Network (CDN).
Install jQuery internally
Visit https://jquery.com/download/ to download the latest version of jQuery. Now put jquery-2.1.3.min.js file into a folder in your Website, for example / jquery .
Now you can include the jquery library in your HTML file as follows:
The jQuery Example
Hello
It will result:
Hello!
Use CDN
You can include the jQuery library in HTML code directly from the Content Delivery Network (CDN). Google and Microsoft provide the latest version.
In this series, we use Google CDN.
For example
Now we rewrite the above example using the jQuery library from Google CDN.
The jQuery Example
Hello
It will result:
Hello!
How to call a jQuery library function?
Similar to JavaScript, before we use jQuery's code to read or edit DOM objects, we need to make sure we start adding events as soon as the DOM is ready.
If you want an event to work on your page, you should call it inside the $ (document) .ready () function. Everything inside will load immediately after the DOM is loaded and before the page content is loaded.
To do this, we register an event ready for the document as follows:
$ ( document ). ready ( function () { // thực hiện khi DOM sẵn sàng });
To call any jQuery library function, use the HTML script tags as below:
The jQuery Example
It will produce the following result:
Click here to see the dialog box.
How to use Custom Script in jQuery?
It is better to write custom code in a custom JavaScript file, named custom.js , as follows:
/* Filename: custom.js */ $ ( document ). ready ( function () { $ ( "div" ). click ( function () { alert ( "Xin chào bạn!" ); }); });
Now let us put this custom.js in the HTML file as follows:
The jQuery Example
It will produce the following result:
Click here to see the dialog box.
Use many libraries in jQuery
You can use multiple libraries together without conflict between them. For example, you can use jQuery libraries and MooTool JavaScript libraries together.
You can check the method: jQuery - noConflict method for more details.
According to Tutorialspoint
Previous article: Handling exceptions (Try / Catch / Finally) in C #
Next lesson: Basic about jQuery
You should read it
May be interested
- How to Use jQuery on Your Websitejquery is the most popular javascript language by far, used by many popular websites across the internet. however, since it is a library, it is not a part of unaltered javascript. how, then, can you use jquery on your website? the process...
- jQuery Ajaxajax stands for asynchronous javascript and xml and this technology helps us to download data from the server without refreshing the browser.
- Tooltip creation tools are useful for jQuerytooltip is a tool that displays a caption for an image or a piece of text when moving the cursor to that text or image. the following article will list useful tooltip creation tools with jquery!
- What is JavaScript? Can the Internet exist without JavaScript?not everyone knows what javascript is and how it works. the long and fascinating development history of javascript as well as what we can do with javascript is still unknown.
- 13 skills needed to become Frontend Developermaster the 13 skills you need below and make sure you have a great front-end developer job!
- How to Enable Cross Origin Resource Sharing (CORS) for Sharing Resource Using Apache Servers, PHP and Jqueryall kinds of interaction on web involve either a client side or a server side. the client side (usually a web browser) launches a request for some resource on server and the server side (usually a php or asp) gives a response back. if the...
- 35 tools, scripts and plugins to build HTML Tablethere are many ways to visualize data, ie you can design a beautiful infographics or create interactive charts. it all depends on your data and how you want to present them.
- Tutorial for creating slideshows in JavaScript with 3 easy stepsif you are studying or interested in programming, do not skip the article below to guide how to create slideshows in java script with 3 simple steps.
- Can Pokemon Go be played on a computer? The answer is yes!by software emulation and additional software to support positioning, we can completely play pokemon go right on the computer, comfortable catching pokemon without worrying about running out of battery when playing as on the phone.
- Summary - How to play Pokemon GO, virtual reality game catch Pokemon on smartphonepokemon go game (styled, raising and training virtual animals) has become popular, the online community with new movements also immediately responded to this mobile game in the direction positive direction