JQuery Interview Questions and Answers
Q1: Define jQuery?
Q2: Why do we use jQuery?
- It helps to develop browser compatible web applications.
- It is very fast and extensible.
- It is effortless to learn and use.
- It supports multiple browsers.
- It facilitates to write minimum lines of code for UI related functions.
- It improves the performance of an application.
Q3: What are the effects methods used in jQuery?
A: jQuery enables us to add effects to make an attractive and interactive web page. The effects like fading, sliding, show/hide, animation, etc. It provides many effects on a web page. Some of them are as follows:
- show() - It enables to display or show the selected elements
- hide() - It allows to hide the matched or the selected elements
- fadeIn() - It allows to show or displays the selected elements by fading it to opaque
- fadeOut() - It enables to show or display the selected elements by fading it to transparent
- toggle() - It allows to show or hide the selected elements
Q4: What is the use of the toggle method in jQuery?
A: The jQuery toggle() is a particular method that is to toggle between the hide() and show() methods.
- Speed: It is an optional parameter that specifies the speed of the delay. Its possible values are slow, fast, and milliseconds.
- Callback: It is also an optional parameter that specifies the function to call after the completion of the toggle() effect
- Easing: It specifies the easing function used for transition
- Display: If the function is true, it displays an element or else it hides the element
Q5: What are the Events in jQuery?
A: Events are nothing but responding to the user's actions on a webpage. It provides simple techniques for connecting event handlers to selections. When the event occurs, the given function will execute.
Q6: List the categories of jQuery events?
A: The frequently used jQuery events are as follows:
- Mouse events: The mouse events such as Scroll, click, double click, mouse up, mouse down, mouse move, mouse leave, mouse enter.
- Keyboard events: The keyboard events like Keys enter, key-down, key-up, and Keypress.
- Browser events: Browser events such as Scroll, load, resize, error, unload
- DOM element events: These are Focus, change, select, blur, focus in, focus out, submit
Q7: What is $() in the jQuery library?
A: The $() function is to wrap an object into a jQuery object that later facilitates to call the several methods that are present in the jQuery object. You can pass a selector string to $() function, and it returns to jQuery objects that contain an array of selected elements. Instead of the $() function, jQuery() function can also be used as they are the same functions.
Q8: Define jQuery Ajax?
Q9: What are the jQuery Ajax events?
A: When there is an Ajax call, at that point the jQuery Ajax events are terminated during the life cycle of the Ajax call. These events are used to display custom messages to the user or to do operations. There are six different jQuery Ajax events. They are as follows:
Q10: What is the use of jQuery Ajax event method ajaxStart()?
A: When the Ajax request is about to send for execution, the jQuery verifies for other Ajax requests. If it doesn’t find any requests, then jQuery triggers the ajaxStart() event. All the event handlers that are registered in the ajaxStart() method get executed.
Q12: What is the use of delay() method in jQuery?
A: The jQuery delay() method that helps to delay the execution of the function in the queue. It sets a timer to delay the execution of the next item in the queue.
$(selector).delay (speed, queueName)
Here, queueName is an optional parameter that specifies the name of the queue. Its default value is fx the standard queue effect.
Q13: What is the use of jQuery Ajax event method of ajaxComplete()?
A: When the Ajax request completes, jQuery triggers the ajaxComplete() event. All the event handlers that are registered in the ajaxComplete() method get executed.
Q14: Does a jQuery library be used for server scripting?
A: jQuery is designed for the purpose of client scripting and it is not suitable for server scripting.
Q15: What is the use of the css() method in jQuery?
A: The jQuery css() method that helps to set style properties or values for selected events or to return the value. It facilitates you to get one or more style properties.
Q16: What is the use of ajax method load()?
A: The ajaxload() method is used to send the HTTP request to load the HTML or text content from the server and adds them to the DOM elements.
Q17: Define Selectors in jQuery and What are the types of selectors?
A: Selector is to find the HTML elements that you want to work on the web page to find or select the element using jQuery.
There are several types of selectors in jquery. Some of them are as follows:
- Name: It is to select the element that matches the given element name.
- .Class: It is to select the element that matches with the given class
- #ID: It is to select a single element that matches the given ID
- Universal(*): It is to select all the elements in DOM
- Attribute selector: It is to select element depending on its attribute value
- Multiple elements E, F, G: It is to select the combined results of all specified selectors E, F, orG
Q18: What is the difference between the ID selector and class selector?
A: Both ID selectors and class selectors are used to select elements as they are in CSS. The main difference is that the ID selector selects the single element that matches the given ID, whereas, class selectors select the multiple elements that match with the given class.
Q19: What are the different types of selector in jQuery?
A: The different types of selectors in jQuery are as follows:
- CSS selector
- XPath selector
- Custom selector
Q20: What is the use of filters in jQuery?
A: jQuery filter is used to filter the specific value from the object. It filters the result of the original query into a particular element.
Q21: Define jQuery UI?
Q22: Define CDN?
A: Content Delivery Network or Content Distribution Network (CDN) is a large distributed system of servers deployed in multiple data centres across the internet. It provides the files from servers at a higher bandwidth that leads to fast loading time. The companies that offer free public CDNs are Google, Yahoo, and Microsoft.
Q23: What are the types of CDN?
A: There are three different types of CDN. They are as follows:
- Peer-to-peer CDN
- Push CDN
- Origin pull CDN
Q24: What are the advantages of using CDN?
A: The advantages of using CDN are as follows:
- Fast browsing experience for the users
- Reduces the resources usage of your parent host, because the bandwidth eating media and theme files are served through CDN
- Low connectivity latency because of the distributed system of servers
- The jQuery library download time will be reduced with the use of CDN. As a result, it also reduces the overall page load time.
Q25: Is jQuery required for bootstrap?
Q26: Differentiate between jquery.min.js and jquery.js?
A: jquery.min.js is a precise version of jquery.js to preserve the bandwidth. Both are the same in terms of functionality, but it is recommended to use the compressed version in the production environment. The efficiency of a web page increases with the use of a minimized version of jQuery.
Q27: What is jQuery Mobile?
A: jQuery Mobile is an HTML5 based user interface system that is designed to create responsive websites and apps that can access on all smartphones, tablets, and desktop devices.
Q28: What is Data table plug-in for jQuery?
Q29: Define QUnit?
Q30: Mentions the benefits of using jQuery Ajax methods?
A: The benefits of using jQuery Ajax methods are as follows:
- Simple techniques to use
- Able to load HTML, JSON, XML, or scripts
- Cross-browser support
- Able to sent POST and GET request