Why do we use jQuery over JavaScript?

jQueryWeb DevelopmentFront End Technology

jQuery is a JavaScript library, so it operates on top of JavaScript. It cannot exist on its own, so you can't use one over the other. You can use just JavaScript or JavaScript and jQuery. jQuery was introduced to make development with JavaScript easier. It will reduce the development time. Use it to add animation and even handling on your website.

jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is easier to use compared to JavaScript and its other JavaScript libraries. You need to write fewer lines of code while using jQuery, in comparison with JavaScript.

Let us see the following code snippet as an example of jQuery and JavaScript to change the background color:


function changeColor(color) {
   document.body.style.background = color;


$ ('body') .css ('background', '#0000FF');

As shown above, both the code snippets are doing the same work of changing the background color. But jQuery takes less code and in this way you can work around other examples, which shows that jQuery minimizes the code and is easier to use.

Updated on 30-Jul-2019 22:30:20