Do you prefer jQuery or JavaScript? Explain Why?were it is used?

jQuery solves major JavaScript problems.
jQuery is preferred over JavaScript due to following reasons.
jQuery is light weight library for developing client side applications including ajax.
jQuery assists to keep code simple and concise and reusable. Huge line of code developed using JavaScript can be eliminated with just few lines of jQuery.
jQuery library simplifies the process of traversal of HTML DOM tree.
jQuery can also handle events, perform animation, and add Ajax support in web applications.
Creating animation and effects using JavaScript is not an easy task and requires deep understanding and imagination. This is quite difficult to do using JavaScript.
When a client wants  to zoom entire screen, or to show a slideshow of photographs, this can be achieved using jQuery.  With a few script includes and smart work , its  possible and extremely effective.  Using  variety of jquery Plugging that are available customization is easy for developers , web developers have control over the effects without even touching a single line of raw Javascript.  Thats the power of query.
If you know the JavaScript well, it helps you to make better use of jQuery.
To distinguish jQuery from JavaScript Here is an example for basic animation using javascript .
view sourceprint?
01.var example = null; // object
02.function doMove() {
03.  example.style.left = parseInt(example.style.left)+1+'px';
04.  setTimeout(doMove,20); // call doMove in 20msec
05.}
06.function init() {
07.  example = document.getElementById('example'); // get the "example" object
08.  example.style.left = '0px'; // set its initial position to 0px
09.  doMove(); // start animating
10.}
11.window.onload = init;
Now if we we wanted to customize the animation or add wavy or some other different animation its quite difficult using JavaScript. But using jQuey its easy to customize using Plug-ins available. The same animation can be achieved using jQuery as
view sourceprint?
1.$("#element").animate({ left: 200px; });
JavaScirpt is a Sea and jQuery is a Ship . Together allow us to sail if used effectively. We should only know when to use what!

Continue to Why to use jQuery ?

0 comments:

Post a Comment