jQuery Interview Questions
1 .
What is the use of delay() method in JQuery?
The jQuery delay() method is used to delay the execution of functions in the queue. It is the best method to make a delay between the queued jQuery effects. The jQUery delay () method sets a timer to delay the execution of the next item in the queue.
 
Syntax :

$(selector).delay (speed, queueName) ​

 


speed : It is an optional parameter. It specifies the speed of the delay. Its possible values are slow, fast and milliseconds.
 
queueName : It is also an optional parameter. It specifies the name of the queue. Its default value is "fx" the standard queue effect.
2 .
What is the use of html() method in JQuery?
The jQuery html() method is used to change the entire content of the selected elements. It replaces the selected element content with new contents.
 
Syntax :

$(document).ready(function(){    
    $("button").click(function(){    
        $("p").html("Hello <b>freetimelearning.com</b>");    
    });    
});​
    
3 .
What is the use of css() method in JQuery?
The jQuery CSS() method is used to get (return)or set style properties or values for selected elements. It facilitates you to get one or more style properties. The jQuery CSS() provides two ways:
 
Return a CSS property

It is used to get the value of a specified CSS property.
 
$(document).ready(function(){    
    $("button").click(function(){    
        alert("Background color = " + $("p").css("background-color"));    
    });    
}); ​
   
 
Set a CSS property

This property is used to set a specific value for all matched element.
 
$(document).ready(function(){    
    $("button").click(function(){    
        $("p").css("background-color", "violet");    
    });    
});  
4 .
Can you use multiple document.ready() function on the same page?
Yes. You can use any number of document.ready() function on the same page.

Example :
 
$(document).ready(function() {    
$("h1").css("background-color", "red");    
 });    
$(document).ready(function() {    
$("p").css("background-color", "blue");    
 }); 
5 .
What is a use of jQuery filter?
jQuery filter is used to filter the specific values from the object. It filters the result of your original query into specific elements.
6 .
What is the use of serialize() method in JQuery?
The jQuery serialize() method is used to create a text string in standard URL-encoded notation. It serializes the form values so that its serialized values can be used in the URL query string while making an AJAX request.
 
Syntax :

$(document).ready(function(){    
    $("button").click(function(){    
        $("div").text($("form").serialize());    
    });    
});
7 .
What is the use of the animate() method in jQuery?
The animate function is used to apply the custom animation effect to elements. Syntax :
$(selector).animate({params}, [duration], [easing], [callback])  
Here,
 
* "param" defines the CSS properties on which you want to apply the animation.

* "duration" specify how long the animation run. It can be one of the following values : "slow," "fast," "normal" or milliseconds

* "easing" is the string which specifies the function for the transition.

* "callback" is the function which we want to run once the animation effect is complete.
8 .
What does the jQuery Ajax event method ajaxComplete() do?
Whenever an Ajax request completes, jQuery triggers the ajaxComplete event. Any and all handlers that have been registered with the .ajaxComplete() method are executed at this time.
9 .
What does the jQuery ajax event method ajaxStart() do?
Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the ajaxStart event. Any and all handlers that have been registered with the .ajaxStart() method are executed at this time.
10 .
What is the difference between onload() and document.ready() methods?
body.Onload() event will be called only after the DOM and associated resources like images get loaded, but jQuery's document.ready() event will be called once the DOM is loaded and it does not wait for the resources such as images to be loaded.