What is jQuery and how to use it
jQuery is the most used JavaScript library available. Its main job is to ease the creation of simple functions to a website. The syntax of jQuery is made very easy to read and it is most often the first JavaScript library that a new web developer becomes familiar with.
You can select elements from a web page, create animations, add and modify events and create ajax functionalities. This is jQuery from google hosted content delivery network:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
It is a script that you can insert into the source of a website.
Overview #
Under the tree jQuery is DOM (Document Object Model) modifying library. For example, from a website you can find an element and change its color, modify text, increase font size, react to click events or hide the element. Everything that can be seen on a web page, can also be modified with jQuery.
It is a really strong library if the DOM is wanted to be modified with ease and in a speedy fashion. It’s in usage in over half of available websites and the learning of it is really easy. The weakness of is the the its size. jQuery is a large library and a lot of things can be achieved by using it. But a lot of smaller libraries specified for exact usage do the same things in a better and more effective way.
jQuery is at its best when the visible elements of a website must be modified dynamically. For example when a user clicks a button, jQuery reacts and shows something new to the user.
Features #
The most important features of jQuery are:
- Selection of DOM elements
- The manipulation of DOM
- Events
- Effects and animations
- Ajax
- Deferred and promise
- Extraction of JSON
- Building on top of jQuery
- Bringing modern technologies to old web browsers
- Support for most web browsers
There are two versions of jQuery. The first and number one version is meant for the users that need support for old browsers. The second version only has support for moderns browsers.
Usage #
To start using jQuery, you need to append the script found at the top of the page to your website.
The usage is simple. Choose and object which you want to do something with and do.
<script type="text/javascript">
$('body').hide() // this hides the body of the website, use show() to show
</script>
The common thing with all jQuery methods is its dollar sign $, a variable that starts all new jQuery actions. The functions are well named and do exactly what they say.
There are hundreds of jQuery functions, some used more than the others but all of them have a special thing they solve. If you need to modify, add or follow something on a web page, you can probably do it with jQuery.