jQuery Interview Questions Part 2

6. Why is jQuery's data method use?


The jQuery's data method is used to associate the data with the DOM nodes and the objects.

Using this method, it helps to make your code more concise and clean.

You can call the data method on a jQuery object, or you can use the $.data() function instead.

For example,

// Using the data method:
$("#myDiv").data("key","arbitrary value");

// Using the data function:
$.data($("#myDiv").get(0),"key","arbitrary value");

7. Is jQuery a replacement of JavaScript?


No, jQuery is not a replacement of JavaScript.

JavaScript is a full-fledged scripting language and JQuary is a specific implementation of JavaScript.

jQuery is a JavaScript library. jQuery compiles and interpretes with the JavaScript compiler and interpreter.

Without JavaScript, jQuery does not even exist. So, we can say that jQuery is for the purpose of assisting JavaScript and not for replacing JavaScipt.

8.  What do you know about jQuery UI?


jQuery UI is a collection of visual effects, widgets, themes, user interface interactions implemented with jQuery, CSS and HTML.

jQuery UI is useful when you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.

It is a powerful theme mechanism, stable and maintenance friendly and has extensive browser support.

9. Which methods are used to provide effects in jQuery?


jQuery provides various amazing effects. Following are the methods used to provide effects in jQuery,

1. animate( params, [duration, easing, callback] ): This function makes custom animations for your HTML elements.

2. fadeIn( speed, [callback] ): This function fades in all the matched elements by adjusting their opacity and firing an optional callback after completion.

3. fadeOut( speed, [callback] ): This function is used to fade out all the matched elements by adjusting their opacity to 0, then setting the display to "none" and firing an optional callback after completion.

4. fadeTo( speed, opacity, callback ): This function fade the opacity of all the matched elements to a specified opacity and firing an optional callback after completion.

5. stop( [clearQueue, gotoEnd ]): This function stops all the currently running animations.

6. Hide(): The hide() method hides each set of matched elements if shown.

7. Toggle() : This method toggles the elements. It toggles the display state of elements between revealed and hidden.

8. Show(): This method shows each of the matched elements if hidden.

10. What are the features of jQuery?


jQuery provides Document Object Model (DOM) which helps to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine.

jQuery offers event handling which helps to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.

jQuery helps you to develop a responsive and feature-rich site using AJAX technology.

jQuery comes with plenty of built-in animation effects which you can use in your websites.

jQuery is very lightweight library - about 19KB in size ( Minified and gzipped ).

jQuery has cross-browser support, and works well in Internet Explorer 6.0+, FireFox 2.0+, Safari 3.0+, Chrome and Opera 9.0+

jQuery supports CSS3 selectors and basic XPath syntax.