Interview questions for JQuery
1. What is jQuery?
2. What are Selectors in jQuery?
A jQuery Selector is a function that uses the expressions to find out matching elements from a DOM based on the given criteria. In a simple language, selectors are used to select one or more HTML elements using jQuery. Once an element is selected then we can perform various operations on that selected element.
Selecting an element in DOM is done with the help of $() construct with a string parameter containing any CSS selector expression. $() will return zero or more DOM elements on which you can apply any effect or style.
3. Is jQuery a programming language?
What are the Advantages of jQuery Ajax methods?
Answer: The advantages of using jQuery Ajax methods are
• Cross-browser support
• Simple methods to use
• Ability to send GET and POST requests
• Ability to Load JSON, XML, HTML or Scripts
4. 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.
5. What is jQuery UI?
We can use interactions for basic mouse-based behaviours to any element. Examples of Interactions are the following:
Mention some advantages of jQuery.
There are many advantages of using jQuery. Some of them include :
• 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.
7. 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.
8. 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. Why do we use jQuery?
o It is very easy to learn and use.
o It is used to develop browser compatible web applications.
o It improves the performance of an application.
o It is very fast and extensible.
o It facilitates you to write minimal lines of codes for UI related functions.
o It provides cross-browser support.
11. What is $() in jQuery library?
The $() function is an alias of jQuery() function. It is used to wrap any object into jQuery object which later facilitates you to call the various method defined jQuery object. You can pass a selector string to $() function, and it returns a jQuery object which contains an array of all matched DOM elements.
12. What are the effects methods used in jQuery?
These are some effects methods used in jQuery:
o show() – It displays or shows the selected elements.
o hide() – It hides the matched or selected elements.
o toggle() – It shows or hides the matched elements. In other words, it toggles between the hide() and shows() methods.
o fadeIn() – It shows the matched elements by fading it to opaque. In other words, it fades in the selected elements.
o fadeOut() – It shows the matched elements by fading it to transparent. In other words, it fades out the selected elements.
13. What is the use of param() method in jQuery?
The param() method is used to represent an array or an object in a serialized manner. While making an ajax request we can use these serialize values in the query strings of URL.
• “object | array” specifies an array or an object to be serialized.
• “boolValue” specifies whether to use the traditional style of param serialization or not.
14. What is jQuery connect and how to use it?
A jQuery connect is a plugin used to connect or bind a function with another function. Connect is used to execute a function from any other function or plugin. It can be used by downloading jQuery connect file from jQuery.com and then include that file in the HTML file. You have to use $.connect to connect one function to another.