Jquery interview question set 2/Jquery Interview Questions and Answers for Freshers & Experienced

How jQuery stores data related to an element?

jQuery.data() method aids in attaching any type of data to DOM elements, free from memory leaks. jQuery makes sure that data is removed along with the DOM elements removed via jQuery methods.

Code for Storing and retrieving data related to an element.

$('#myDiv').data('keyName', { foo : 'bar'});
$('#myDiv').data('keyName'); // { foo : 'bar'}

Posted Date:- 2021-09-01 05:51:51

What is the difference between jQuery.get() and jQuery.ajax() ?

jQuery.ajax() method is used to send HTTP Ajax requests, whereas jQuery.get() method is used to send HTTP GET requests to load data from the server.

Posted Date:- 2021-09-01 05:51:07

What is Method Chaining in jQuery? What advantages does it offer?

With jQuery method chaining, multiple actions can be applied on a single line of code, as all the methods return jQuery objects that can be utilized to call another method.

Without chaining, jQuery methods are called one after another in a separate line, whereas with chaining, jQuery methods are written in dot separated single line of code.

Without chaining multiple lines of code that need to be written, making jQuery to search entire DOM for matched element, then single methods in each line of code are applied. Whereas Chaining needs only a one-time selection of a matched element from DOM, by making better performance.

Posted Date:- 2021-09-01 05:50:28

What is the use of the val() method in jQuery?

.val() method helps to find the value of an attribute of HTML element. For example, form elements such as input, select and textarea. Val() is also applied to find the value of all matched elements from checkboxes and radio buttons as well as a drop-down list.

Posted Date:- 2021-09-01 05:49:43

What is the use of the serialize() method in jQuery?

It serializes the form values so that its serialized values can be used in the URL query string while making an AJAX request.

.serialize() method of jQuery returns the input values of HTML form in the form of string.

Posted Date:- 2021-09-01 05:49:00

Describe the functionality of read cookies, write cookies and delete cookies in jQuery.

When websites are visited, cookies are data values such as the name of the user that gets stored in small text files on the computer. While revisiting websites, the cookies help to remember the user’s name. JavaScript and jQuery create, read and delete cookies, with the document.cookie property.

Posted Date:- 2021-09-01 05:48:16

Differentiate between width() vs css(‘width’) in jQuery.

There are two different methods in jQuery to change the width of an element. The first way is to use .css(property) and the other way is to use .property().


In .css(property) which in this case is width, we have to add px in the value_change, say 300px.

We can use .property(value_change), which in this case is width, and you need not have to add px, but direct value.

Posted Date:- 2021-09-01 05:47:36

What is jQuery Effects - Fading?

The fade methods define visibility of content in UI, in other words how the web page is hidden/shown. To use the fade methods of jQuery I need a jQuery library in my project, so I directly used the Google AJAX Libraries content delivery network to serve jQuery from Google. Doing so has several advantages over hosting jQuery on our server, decreased latency, increased parallelism, and better caching. We add the script to our project.

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

Our UI design is ready so now implement the fade methods. Here are the four types of jQuery fade methods:


Posted Date:- 2021-09-01 05:46:21

What is jQuery UI Sortable and how to use it?

The jQuery UI is a library provided by jQuery for a better user interface. Using sortable we can reorder the DOM elements in the defined area. Users have to click on the item and drag that item to a new place. The other items will be automatically arranged. Accordingly, use the following procedure to enable sortable elements:

1. Include the jQuery js file.
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.10.0.min.js"></script>
2. Include the jQuery UI js file.
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>

Posted Date:- 2021-09-01 05:45:25

What is chaining in jQuery?

Chaining is a powerful feature of jQuery. This means specifying multiple functions and/or selectors to an element. Chaining reduces the code segment and keeps it very clean and easy to understand. Generally, chaining uses the jQuery built-in functions that make the compilation a bit faster.

For example:

$(document).ready(function() {
$("#div2").html($("#txtBox").prop("readonly")) + '</br>';

Posted Date:- 2021-09-01 05:44:00

How to add and remove CSS classes to an element using jQuery?

You can use the addClass() and removeClass() methods to do the same.


Posted Date:- 2021-09-01 05:42:31

What is the use of the toggle() method in JQuery?

If there is a click event, toggle() attaches functions to toggle. So, on first click first action occurs, on second, second action and so on.

<button>Change my color on each click</button>
function(){$("button").css({"color": "blue"});},
function(){$("button").css({"color": "yellow"});},
function(){$("button").css({"color": "red"});

Posted Date:- 2021-09-01 05:41:31

Difference between prop and attr?

Both attr() and prop() can be used to set or get an element’s value, however attr() returns the original (default) value whereas prop() returns the most recent (current) value. For example, if a text input had an initial value of ‘Male,’ and later it was changed by the user to ‘female,’ attr() will return the value as ‘Male’ whereas prop() will return the value as ‘female.’

Posted Date:- 2021-09-01 05:40:45

What are all the ways to include jQuery on a page?

1. You can use <script> to add the library in the HTML <head> or <body> tag: <script src='jquery-3.2.1.min.js'></script>
2. Write the code within the HTML document inside the <script> tag, here we have used cdn link.
<script src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.js'></script>
<script type = “text/javascript”>
$(document)……… <jQuery code>
3. Include the .js file, which has the jQuery code into the HTML document.
<script src='script.js' type="text/javascript"></script>

Posted Date:- 2021-09-01 05:39:41

What is the difference between Map and Grep function in jQuery?

In $.map() you need to loop over each element in an array and modify its value whilst the $.Grep() method returns the filtered array using some filter condition from an existing array. The basic structure of Map() is:

$.map ( array, callback(elementOfArray, indexInArray) )
Syntax for $.Grep():

jQuery $.grep() Method

Posted Date:- 2021-09-01 05:37:22

List the four parameters used for the jQuery Ajax method.

URL address where the request is sent, Type of request viz GET or POST, Data/content to be sent to the server and condition for the browser to either allow or not cache the page requested are the four parameters used for jQuery Ajax method.

Posted Date:- 2021-09-01 05:36:22

Can you give some situations or scenarios for using jQuery?

We can use jQuery in the following situations/scenarios:

<> We can apply a jQuery function that can change CSS static or dynamic property.
<> We can call functions on events such as Form events, Keyboard events, Mouse events, Browser events with the help of jQuery.
<> We can manipulate (add, edit or delete) DOM elements using jQuery.
<> jQuery can be used for animation effects on the HTML element by gradually changing its static position to another position.

Posted Date:- 2021-09-01 05:35:51

Can I use a jQuery library for server scripting?

jQuery is a client-side scripting Javascript library. It can not be used for server-side scripting.

Posted Date:- 2021-09-01 05:34:47

Identify any difference between .detach() and .remove() of jQuery.

detach() method of jQuery removes the selected element, however it retains data and events. .remove() method of jQuery removes elements, data as well as events.

Posted Date:- 2021-09-01 05:34:12

Explain any of the advantages of hosting a jQuery from CDN.

Hosting jQuery from the Content Delivery Network (CDN) helps in high availability and high performance at a lower cost and low network load, improved latency (lesser time is taken to send and receive a data packet from server), offer a device-specific version of contents.

Posted Date:- 2021-09-01 05:33:41

What are jQuery plugins?

Plugins are a piece of code. The jQuery plugins are a code written in a standard JavaScript file. These JavaScript files provide useful jQuery methods that can be used along with jQuery library methods.
Any method you use in plugins must have a semicolon (;) at the end. The method must return an object unless explicitly noted otherwise. It produces clean and compatible code that way. You have to prefix the filename with jQuery, follow that with the name of the plugin and conclude with .js.

Posted Date:- 2021-09-01 05:33:07

What is queue() in Jquery? Use of queue() in jquery?

Delay comes under the custom effect category in jQuery. Its sole use is to delay the execution of subsequent items in the execution queue.
queueName is the name of the queue in which the delay time is to be inserted. By default, it is an “fx” queue. An “fx” queue is also known as an effects queue.

delay( duration [, queueName ] )

Posted Date:- 2021-09-01 05:32:03

What is jQuery Datepicker in jQuery?

The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.

Posted Date:- 2021-09-01 05:30:42

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.


$("p").html("Hello <b>edureka</b>");

Posted Date:- 2021-09-01 05:29:52

Explain the functionality of jQuery UI (user interface).

jQuery UI is a jQuery library, that provides building various user interface objects such as multiple record lists where the users can select, sort, drag, drop as well as resize particular DOM elements.

UI library also creates built-in widgets such as auto-complete, checkbox, radio buttons, datepicker, menu, etc. as well as adding an effect hide, show or toggle, and other animations.

Posted Date:- 2021-09-01 05:29:07

Differentiate between jquery.min.js and jquery.js

jquery.min.js and jquery.js have the same functionality, jquery.min.js has all empty spaces removed in order to make the file smaller in size and faster to load resulting in script execution.

Having JS files minified in a production environment means that they will load faster and give quick and better page performance.

Posted Date:- 2021-09-01 05:28:36

Explain the Applications for jQuery Mobile.

jQuery Mobile is an open-source cross-browser compatible framework designed to build mobile applications accessible on all smartphones, tablet and desktop devices.

jQuery Mobile is created on jQuery and User Interface of jQuery for rendering various special effects, handling Ajax request/responses, touch events, along with a variety of widgets.

Posted Date:- 2021-09-01 05:28:11

What are the four parameters used for the jQuery Ajax method?

The four parameters are:

1. URL: URL for sending the request
2. Type: GET/POST request
3. Success: the callback function when the request is successful
4. DataType: return data type – HTML, XML, text etc.

Posted Date:- 2021-09-01 05:27:16

Briefly explain the bootstrap and JavaScript plug-in.

Bootstrap is a framework or toolset that includes HTML, CSS, and JavaScript to build a webpage or web application. Many of Bootstrap components require Javascript plugins to function.

Posted Date:- 2021-09-01 05:24:54

Differentiate between the ID and Class selector in jQuery.

Each HTML element can have only one ID, in other words, an element can be identified with a unique ID, whereas you can use the same class on multiple elements.

Example of ID selector in jQuery in order to hide a DOM element with an ID as its attribute, say <div> element with an ID as “gold_coin”

If you want to hide, say all links having its class as “raw”,


Posted Date:- 2021-09-01 05:24:22

What is the difference between $(window).load and $(document).ready function in jQuery?

$(window).load is an event that fires when the DOM and other contents on the page is fully loaded. This event is fired after the ready event.
In most cases, the script can be executed as soon as the DOM is fully loaded. The ready() is usually the best place to write your JavaScript code. But there could be some scenario where you might need to write scripts in the load() function. For example, to get the actual width and height of an image.

The $(window).load event is fired once the DOM and all the CSS, images and frames are fully loaded. So, it is the best place to write the jQuery code to get the actual image size or to get the details of anything that is loaded just before the load event is raised.

Posted Date:- 2021-09-01 05:23:23

What is the difference between bind() vs live() vs delegate() methods in jQuery?

bind(): this method registers the event handler directly to the required DOM element. E.g.:

$(“#members a”).bind(“click”, function(f){….});
This means any matching anchors will have this event handler attached!

live(): this method attaches the event handler to the root of the document. This means one handler can be used for all events that propagated to the root. The handler is thus attached only once.

delegate(): in this method, you can choose where to attach the handler. This is the most efficient and robust method for delegation.


$(“#members”).delegate(“ul li a”, “click”, function(f){….});

Posted Date:- 2021-09-01 05:22:43

Differentiate among .empty() vs .remove() vs .detach() in jQuery.

remove(): removes the element as well as its child elements. Data from DOM can be restored; however, event handlers can’t be restored.

empty(): does not remove the element; however, remove its content, and the associated child elements

detach(): removes the element and all the associated child elements, but retains the data and event handlers of the removed element to be reused later.

Example usage:


Posted Date:- 2021-09-01 05:21:44

What is jQuery.noConflict?

Usually, JS functions and variables use $ as a name. In jQuery, $ is just an alias for jQuery, so we don’t need to use $. If we have to use a JS library along with jQuery, the control of $ is given to the JS library. To give this control, we use jQuery.noConflict(). It is also used to assign a new name to a variable.

var newname = jQuery.noConflict();

Posted Date:- 2021-09-01 05:20:51

Explain the difference between the .detach() and remove() methods in jQuery.

The detach() and remove() methods are the same, except that .detach() retains all jQuery data associated with the removed elements and .remove() does not. detach() is therefore useful when removed elements may need to be reinserted into the DOM later.

Posted Date:- 2021-09-01 05:19:49

What is the advantage of hosting a jQuery using a CDN?

CDN stands for Content Delivery Network or Content Distribution Network. It is a large distributed system of servers deployed in multiple data centers across the internet. It provides the files from servers at a higher bandwidth that leads to faster loading time.

1. The jQuery library download time will be reduced. For example - Users in Europe will hit the CDN in Europe, and users in the US will hit the US CDN. As a result, this will reduce the overall page load time.

2. The jQuery library will already be cached in the user’s browser if the user visited another website that references the same jQuery library. In this case, the user need not download the jQuery library.

Posted Date:- 2021-09-01 05:19:14

What is Qunit?

QUnit is a powerful, easy-to-use JavaScript unit testing framework. It's used by the jQuery, jQuery UI, and jQuery Mobile projects and is capable of testing any generic JavaScript code.

Posted Date:- 2021-09-01 05:18:15

What is a Data Table plug-in for jQuery?

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, built upon the foundations of progressive enhancement, which adds advanced features to any HTML table.

Posted Date:- 2021-09-01 05:17:51

Is it possible that jQuery HTML works for both HTML and XML documents?

No, jQuery HTML only works for HTML documents. It doesn't work for XML documents.

Posted Date:- 2021-09-01 05:17:24

What is the difference between jquery.min.js and jquery.js?

jquery.min.js is a compressed version of jquery.js(whitespaces and comments are removed, shorter variable names are used, and so on) to preserve bandwidth. In terms of functionality, they are absolutely the same. It is recommended to use this compressed version in the production environment. The efficiency of a web page increases when the minimized version of jQuery is used.

Posted Date:- 2021-09-01 05:17:02

What is jQuery connect?

A ‘ jQuery connect’ is a plug-in used to connect or bind a function with another function. Connect is used to execute a function whenever a function from another object or plug-in is executed.

Posted Date:- 2021-09-01 05:16:09

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.the ready() event will be called once the DOM is loaded, and it does not wait for the resources such as images to be loaded.

Posted Date:- 2021-09-01 05:15:41

Define jQuery UI Autocomplete ?

Autocomplete is one of the best widgets ON websites and is used in nearly all websites. jQuery has a powerful widget, autocomplete, and in this article I will try to explain how to use jQuery Autocomplete in websites. All the way and all other features of autocomplete. We can make autocomplete, using AJAX, to call to build a list (server-side) and then bind that list into a text box using JavaScript. However there are other alternatives to make autocomplete rather then this in an easy way. The most robust and efficient tool of autocomplete is jQuery-ui autocomplete and this tool is free and there is no need to license it.

Points to remember

1. The Autocomplete widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS as a starting point.
2. This widget manipulates its element's value programmatically, therefore a native change event may not be fired when the element's value changes.

Posted Date:- 2021-09-01 05:15:01

What $(document).ready(function()) is and when to use it?

$(document).ready(function()) is a jQuery event that fires as soon as the DOM is fully loaded and ready to be manipulated by script. This is the earliest point in the page load process where the script can safely access elements in the page's HTML DOM. This event is fired before all the images and CSS are fully loaded.

Posted Date:- 2021-09-01 05:14:02

What is the history of jQuery UI and how to use it?

jQuery UI is really very easy to learn and it provides abstractions for low-level interaction and animation, advanced effects and high-level, theme-able widgets, built on top of the jQuery JavaScript Library which you can use to build highly interactive web applications. The whole jQuery UI is categorized into four groups; they are core, interactions, widgets and effects.

The components of jQuery UI are:

<> Core: It's a perquisite for other widgets and effects to work properly.
<> Interactions: It allows us to add behavior like Draggable, Droppable, Sortable, etc on the UI elements.
<> Widgets: It provides UI controls like tabs, dialog, slider, etc.
<> Effects: It provides ready to use effects like clip, bounce, explode, etc.

Posted Date:- 2021-09-01 05:13:35

What is the usage of Draggable, Droppable, Resizable, Selectable in jQuery UI?

There are only 5 plugins available in the interaction section; that is Draggable, Droppable, Resizable, Selectable and Sortable. Interaction Plugins handles complex behaviors such as drag and drop, resizing, selection and sorting.

Draggable: It enables draggable functionality on any DOM element. Move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport.

Droppable: It enables any DOM element to be droppable, a target for draggable elements.

Resizable: It enables any DOM element to be resizable. With the cursor, grab the right or bottom border and drag to the desired width or height.

Selectable: It enables a DOM element (or group of elements) to be selectable. Draw a box with your cursor to select items. Hold down the Ctrl key to make multiple non-adjacent selections.

Sortable: It enables a group of DOM elements to be sortable. Click on and drag an element to a new spot within the list, and the other items will adjust to fit. By default, sortable items share draggable properties.

Posted Date:- 2021-09-01 05:12:05

Define Add or Remove class in jQuery?

addclass will be used for adding a new CSS class after replacing the old class and removeClass will work for removing the selected class.

$(document).ready(function() {
$('.button').click(function() {
if (this.id == "add") {
$('#animTarget').addClass("myClass", "fast")
} else if (this.id == "toggle") {
$('#animTarget').toggleClass("myClass", 1000, "easeOutSine")
} else if (this.id == "switch") {
$("#animTarget").switchClass("myClass", "switchclass", "fast")
} else {
$('#animTarget').removeClass("myClass", "fast")

Posted Date:- 2021-09-01 05:11:06

What is resize() function in jQuery?

This method in jQuery is used for changing of the size of the element. You can use by .resize() function.

Posted Date:- 2021-09-01 05:10:37

What is the difference between bind() and live() method in jQuery ?

The binding of event handlers are the most confusing part of jQuery for many developers working on jQuery projects. Many of them unsure of which is better to use. In this article we will see the main differences between Bind and Live methods in jQuery.

Bind() Method

The bind method will only bind event handlers for currently existing items. That means this works for the current element.


$(document).ready(function () {
$('P').bind('click', function () {
alert("Example of Bind Method");

Live() Method
The Live method can bind event handlers for currently existing items or future items.


$(document).ready(function() {
$('P').live('click', function() {
alert("Example of live method");
$('body').append('<p>Adding Future items</p>');


Posted Date:- 2021-09-01 05:10:00

What are jQuery plugins?

Plugins are a piece of code. In jQuery plugins it is a code written in a standard JavaScript file. These JavaScript files provide useful jQuery methods that can be used along with jQuery library methods.

Any method you use in plugins must have a semicolon (;) at the end. The method must return an object (jQuery), unless explicitly noted otherwise. Use each to iterate over the current set of matched elements. It produces clean and compatible code that way. Prefix the filename with jQuery, follow that with the name of the plugin and conclude with .js. (For example, jquery.plug-in.js). Always attach the plugin to jQuery directly instead of $, so users can use a custom alias via the noConflict() method (via the jQuery Team).

Posted Date:- 2021-09-01 05:09:14

R4R Team
R4R provides Jquery Freshers questions and answers (Jquery Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Jquery interview question set 2,Jquery Freshers & Experienced Interview Questions and Answers,Jquery Objetive choice questions and answers,Jquery Multiple choice questions and answers,Jquery objective, Jquery questions , Jquery answers,Jquery MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Jquery fresher interview questions ,Jquery Experienced interview questions,Jquery fresher interview questions and answers ,Jquery Experienced interview questions and answers,tricky Jquery queries for interview pdf,complex Jquery for practice with answers,Jquery for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .