jQuery Interview Questions

1) Define Find and Children Method?

In DOM tree if you have to find all the method we use Find Method whereas if to find the single level we can use Children Method.

2) Is it necessary to add jQuery file in Master as well as Content page?

No, if we add jQuery file in Master page then content page can directly access to it.

3) Are size and length similar in jQuery?

NO, they both return the number but size is a method and length is a property where as length is faster in execution than size.

4) Describe onload() and document.ready()?

Basic difference between them is onload() can only be use once in a page where document.ready() can be used multiple times.

document.ready(): it is called only when DOM is loaded but

onload(): it is called when DOM as well as image is loaded.

5) Enlist the slowest and fastest selector in jQuery.

Fastest Selectors: ID selector and Element selector.

Slowest Selector: Class selector.

6) What can replace the '$' sign in jQuery?

To replace '$' sign we can use "No Conflict" method which is used as reference for jQuery and save it in a variable.

7) Enlist the type of selector.


8) What is the difference between $(this) and this keyword in jQuery?

  1. $(this) keyword returns a jQuery object whereas this key word doesn't.
  2. this keyword represents the current element which denotes the current DOM element.

9) Are detach() and remove() function same?

No, There functionality is same as both removes the DOM element but detach() heep track of last element detached as we can reattach that element but remove() doesnot.

10) How to add or remove specified class if not present?

By using toggleClass(class) function which can add or remove specified class.

11) What is jQuery connect?

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.

12) What is the use jQuery.data method?

jQuery.data methods is used to associate the data with the DOM nodes and the objects. This data method makes the jQuery code clear and concise.

13) 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.

14) What is the use of jQuery filter?

The jQuery filter is used to filter the certain values from the object list based on the criteria. Example is to filter certain products from the master list of products in a cart website.

15) What is used for testing jQuery?

QUnit is used to test jQuery and it is very easy and efficient.

16) What is CDN?

CDN (Content Distribution Network) is said to be a group of companies in different location with network containing copies of data files to maximize bandwidth in accessing the data.

17) Enlist types of CDN?

There are 2 types of CDN:

  • Microsoft: Load jQuery from Ajax CDN
  • Google: Load jQuery from Google libraries API

18) What is the script build up by jQuery?

jQuery build a JavaScript file. It is single javascript file that contains common DOM, event effects and Ajax functions.

19) What are method to include jQuery in a page?

Following are the ways to include jQuery in a page:

  • Local copy inside script tag
  • Remote copy of jQuery.com
  • Remote copy of Ajax API
  • Local copy of script manager control
  • Embedded script using client script object

20) What is called chaining?

Chaining is used to connect multiple events and functions in a selector.

21) Where jQuery code is getting executed?

jQuery code is getting executed on a client browser.

22) How JavaScript and jQuery are different?

JavaScript is a language while jQuery is a library built in the JavaScript language that helps to use the JavaScript language.

23) What is the use of jquery .each() function?

The $.each() function is used to iterate over a jQuery object. The $.each() function can be used to iterate over any collection, whether it is an object or an array.

24)What is the difference between parent() and parents() methods in jQuery?

The basic difference is the parent() function travels only one level in the DOM tree, where parents() function search through the whole DOM tree.

25) 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.