jQuery Interview Questions and Answers
- What is jQuery ?
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM) and JavaScript.
Elaborating the terms, jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser JavaScript development. - Does jQuery HTML work for both HTML and XML documents ?
No, JQuery HTML doesn’t work with XML document. It only works for HTML documents. - What are jQuery Selectors ? Give some examples.
jQuery selectors are used to select the HTML elements and allows you to manipulate the HTML elements in a way we want. It selects the HTML elements on a variable parameter such as their name, classes, id, types, attributes, attribute values, etc. All selectors in jQuery are selected using a special sign i.e. dollar sign and parentheses:$("selector-name")
- Elements Selector: The elements selector selects the element on the basis of its name.
Example:$("h1")
- Id Selector: The id selector selects the element on the basis of its id.
Example:$("#gfg")
- Class Selector: The class selector selects the element on the basis of its class.
Example:$(".GFG")
- Elements Selector: The elements selector selects the element on the basis of its name.
- What are the advantages of jQuery ?
- It contains wide range of plug-ins. jQuery allows developers to create plug-ins on top of the JavaScript library.
- Large development community.
- It has a good and comprehensive documentation.
- It contains lots of JavaScript library and it is easy to use compared to the standard JavaScript.
- jQuery lets users develop Ajax templates with ease, Ajax enables a sleeker interface where actions can be performed on pages without requiring the entire page to be reloaded.
- Being lightweight and a powerful chaining capability makes jQuery more strong.
- What are the methods used to provide effects?
Some of methods are listed below which provides the effect: - Difference between .empty(), .remove() and, .detach() in Jquery ?
- jQuery empty() Method: The empty() method in jQuery is used to remove all child nodes and its content for the selected elements.
- jQuery remove() Method: The remove() method in JQuery is used to remove all the selected elements including all the text. This method also remove data and all the events of the selected elements.
- jQuery detach() Method: The detach() method in jQuery is used to remove the selected elements from the DOM tree including its all text and child nodes but it keeps the data and the events. Document Object Model (DOM) is a World Wide Web Consortium standard. This defines for accessing elements in the DOM tree.
- Note: The remove() method is faster than empty() or detach() method.
- Is jQuery a JavaScript or JSON library file ?
jQuery is a library of JavaScript file and it consists of DOM event effects and also the Ajax functions. jQuery is alleged to be one JavaScript file. - What are the various ajax functions available in Jquery ?
Ajax allows the user to exchange data with a server and update parts of a page without reloading the entire page. Some of the functions of ajax are as follows:- jQuery ajaxSetup() Method: The ajaxSetup() method is used to set the default values for future AJAX requests.
- jQuery ajax() Method: The ajax() method is used to perform an AJAX request or asynchronous HTTP request.
- jQuery getScript() Method: The getScript() method is used to run a JavaScript using AJAX HTTP GET request.
- jQuery getJSON() Method: The getJSON() method fetches JSON-encoded data from the server using a GET HTTP request.
- Mention the compatible operating systems with jQuery.
- Mac
- Windows
- Linux
- How to include the jQuery library in the ASP.Net project ?
- Download the jQuery library from jQuery.com
- include that reference in the asp.net page.
- Explain bind() vs live() vs delegate() methods in jQuery.
The bind() method does not attach the events to those elements that are added once DOM is loaded whereas live() and delegate() methods attach events to the future elements also.The difference between live() and delegate() methods is that the live() function does not work in chaining. It will work only on a selector or an element while delegate() method will work in chaining.
- Write the command that gives the version of jQuery ?
The command$.ui.version
returns jQuery UI version. - What is jQuery connect ?
A jQuery connect is a plugin that is used to connect or bind a function with another function. Connect is used to execute the function from the other function or plugin is executed. - How to use connect ?
- Download jQuery connect file from jQuery.com
- Include that file in the HTML file.
- Use $.connect function to connect a function to another function.
- What is the use of param() method in JQuery ?
The param() method in jQuery is used to create a serialized representation of an object. - Difference between $(this) and this in jQuery ?
The this and $(this) references are same but the difference is “this” is used in the traditional way but when “this” is used with $() then it becomes a jQuery object. - Difference between find and children methods ?
The find() method is used to find all the descendant elements of the selected element and the children() method is used to find all the children element related to that selected element. - In what scenarios jQuery can be used ?
jQuery can be used in following scenarios:- Mainly for Animation effects
- Manipulation purpose
- Calling functions on events
- Apply CSS static or dynamic
- How to read, write and delete cookies in jQuery ?
We can deal with cookies in jquery using Dough cookie plugin. Dough is easy to use and has powerful features.- Create cookie:
$.dough(“cookie_name”, “cookie_value”); - Read Cookie:
$.dough(“cookie_name”); - Delete cookie:
$.dough(“cookie_name”, “remove”);
- Create cookie:
- Features of jQuery which are used in web applications ?
jQuery uses features like Sliding, File uploading and accordian in web applications.
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.
You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
Please Login to comment...