Dec 18

Jquery Question and Answer part-1

Q1. What are the methods used to provide effects?
Ans. Following are effects Methods.


Q2. Is jQuery is a JavaScript or JSON library file?
Ans. jQuery is a library of JavaScript file and it consists of DOM, event effects and the Ajax functions.

Q3. Which command will give a version of jQuery?
Ans. The command $.ui.version returns jQuery UI version.

Q4. In what scenarios jQuery can be used?
Ans. jQuery can be used in following scenarios:

1. For Animation Effects
2. Calling Function on events
3.  Apply CSS static or dynamic
4. Manipulation purpose

Q5. What is jQuery connect?
Ans.  A ‘ jQuery connect’  is a plugin used to connect or bind a function with another  function. Connect is used to execute function from any other function or plugin is executed.

Q6. What is the difference between eq() and get() methods in jQuery?
Ans. eq() returns the element as a jQuery object. This method constructs a new jQuery object from one element within that set and returns it.
get() return a DOM element. The method retrieve the DOM elements matched by the jQuery object. But as it is a DOM element and it is not a jQuery-wrapped object.

Q7. What is the difference between parent() and parents() methods in jQuery?
Ans. parent() function work only one level in the DOM tree. But parents() function search through whole DOM tree.

Q8. How to disable jQuery animation?
Ans. using “jQuery.fx.off” we can disable jQuery animation. When it set true then disable all jQuery animation. We can use “.stop()” to stop current running animation.

Q9. What is the difference between .empty(), .remove() and .detach() methods in jQuery?
Ans. .empty(): This method removes all the child element of the matched element .
.remove(): Use .remove() when you want to remove the element itself, as well as everything inside it.
.detach(): This method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements.

Q10. What is the difference between event.PreventDefault, event.stopPropagation  and “return false”?
Ans. e.preventDefault() will prevent the default event from occurring, e.stopPropagation() will prevent the event from bubbling up and return false will do both.

Q11. What are various methods to make ajax request in jQuery?
Ans. Using below jQuery methods, you can make ajax calls.

  • load() : Load a piece of html into a container DOM
  • $.getJSON(): Load JSON with GET method.
  • $.getScript(): Load a JavaScript file.
  • $.get(): Use to make a GET call and play extensively with the response.
  • $.post(): Use to make a POST call and don’t want to load the response to some container DOM.
  • $.ajax(): Use this to do something on XHR failures, or to specify ajax options on the fly.

Q12. Can we execute/run multiple Ajax request simultaneously in jQuery? If yes, then how?
Ans. YES, using jQuery .when() method which provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
Instead of waiting for first ajax request to complete and then issue the second request is time consuming. The better approach to speed up things would be to execute multiple ajax request simultaneously.

Example :

$(document).ready( function() {

$.when($.getJSON(URL, {



$.getJSON(URL, {
})).then (function(res1, res2){

$.each(res1[0].items, function (i, item) {


//write code


$.each(res2[0].items, function (i, item) {






Q13.What is finish method in jQuery?
Ans. The .finish() method stops all queued animations and places the element(s) in their final state.

Q14. What is the difference between calling stop(true,true) and finish method?
Ans. The .finish() method is similar to .stop(true, true) in that it clears the queue and the current animation jumps to its end value.

Q15. Why there are two different version of jQuery library?
Ans. Query library comes in 2 different versions.

  1. Development
  2. Production/Deployment

The development version is quite useful at development time as jQuery is open source and if you want to change something then you can make those changes in development version. But the deployment version is minified version or compressed version so it is impossible to make changes in it.

Q16. What are selectors in jQuery and how many types of selectors are there?
Ans. To work with an element on the web page, first we need to find them. To find the html element in jQuery we use selectors. There are many types of selectors but basic selectors are:

  • Name: Selects all elements which match with the given element Name.
  • #ID: Selects a single element which matches with the given ID
  • .Class: Selects all elements which match with the given Class.
  • Universal (*): Selects all elements available in a DOM.
  • Multiple Elements E, F, G: Selects the combined results of all the specified selectors E, F or G.
  • Attribute Selector: Select elements based on its attribute value.

Q17. What is .siblings() method in jQuery?
Ans. When we want to fetch siblings of every elements in the set of matched elements then we can use siblings() method.



Q18. What is jQuery.holdReady() function?
Ans. By using jQuery.holdReady() function we can hold or release the execution of jQuery’s ready event. This method should be call before we run ready event.



Q19. How to read, write and delete cookies in jQuery?
Ans. We can use jQuery cookies plugin for read, write and delte cookies.

Write Cookies

$.cookie("name", "value");

Read Cookies
alert( $.cookie("name") );

Delete Cookie

Q20. What is difference between prop and attr?
Ans. In jQuery both prop() and attr() function is used to set/get the value of specified property of an element.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>