jQuery Interview Questions
1 .
What are selectors in jQuery? How many types of selectors in jQuery ?
If you want to work with an element on the web page, first you need to find it. Selectors are used to find the HTML elements in jQuery. There are many types of selectors. Some basic selectors are:

1. Name Selectors - It is used to selects all elements which match with the given element Name. Ex : $("p") ,  $("h1"),  $("h2"), etc.
2. ID(#) Selectors  - It is used to selects a single element which matches with the given ID. Ex : $("#test") 
3. class(.) Selectors - It is used to selects all elements which match with the given Class. Ex : $(".test")

and more selectors please click here!
2 .
How to read, write and delete cookies in jQuery ?
To deal with cookies in jQuery we have to use the ftl cookie plugin.

1. Create cookie : $.ftl("cookie_name", "cookie_value");
2. Read Cookie : $.ftl("cookie_name");
3. Delete cookie : $.ftl("cookie_name", "remove");
3 .
What is difference between jQuery.get() and jQuery.ajax() method ?
ajax() method is more powerful and configurable, allows you to specify how long to wait and how to handle error, get() is a specialization to over ajax just to retrieve some data.

4 .
What is the difference between .empty(), .remove() and .detach() methods in jQuery ?
All these methods .empty(), .remove() and .detach() are used for removing elements from DOM but they all are different.

.empty() : This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.

.remove() : Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

.detach() : This method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.

5 .
What are the four parameters used for jQuery Ajax method ?
The four parameters are

URL : Need to specify the URL to send the request
type : Specifies type of request(Get or Post)
data : Specifies data to be sent to server
Cache : Whether the browser should cache the requested page
6 .
What is the use of jQuery load method ?
jQuery load method is a powerful AJAX method which is used to load the data from a server and assign the data into the element without loading the page.
7 .
What are various methods to make ajax request in jQuery ?
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 (e.g. cache: true) on the fly.
8 .
What is jQuery UI ?
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library that can be used to build interactive web applications.
9 .
Mention some advantages of jQuery.
There are many advantages of using jQuery. Some of them include :
 
   It is like an enhanced version of JavaScript so there is no overhead in learning a new syntax.
 
   jQuery has the ability to keep the code simple, readable, clear and reusable.
 
   It has Cross-browser support.
 
   This would remove the requirement for writing complex loops and DOM scripting library calls.
 
   jQuery helps in event detection and handling.
 
   It provides tons of plug-ins for all kind of needs.
10 .
What is the purpose of fadeToggle() method in JQuery?
he jQuery fadeToggle() method is used to toggle between the fadeIn() and fadeOut() methods. If the elements are faded in, it makes them faded out, and if they are faded out, it makes them faded in.
 
Syntax :
$(selector).fadeToggle();  
$(selector).fadeToggle(speed,callback);   
$(selector).fadeToggle(speed, easing, callback);  
 
speed : It is an optional parameter. It specifies the speed of the delay. Its possible values are slow, fast and milliseconds.
 
easing: It specifies the easing function to be used for transition.
 
callback: It is also an optional parameter. It specifies the function to be called after completion of fadeToggle() effect.