jQuery is a fast, lightweight and concise JavaScript library that supports all browsers. It is easy to play with DOM, event handlings, animations, and AJAX interactions for fast web development with jQuery. Its slogan "minimal lines of code" helping the developers to write a few lines of code to do the most things. Moreover, jQuery is active and "rival" cooperation. It seems to be in the overall development of JavaScript, not just to one's private ends.
11th Dec, 2019
35
JavaScript
Sharad Jaiswal
Below are few major features of Jquery
Q1. What is JQuery?
JQuery is the most popular JavaScript library due to it’s lightweight and extendable functionality used for creating efficient websites. It provides an easy method for HTML DOM traversing and manipulation and client-side animations. The purpose of jQuery is to make the code simple, short and readable.
For using jQuery one should have prior knowledge of HTML, CSS, and JavaScript.
Q2. Enlist few advantages of using Jquery?
Advantages of using jQuery:
Q3. What are the core features of jQuery?
jQuery library contains the following features:
Q4. What is the difference between JavaScript and jQuery?
Q5. What are the different type of selectors in Jquery?
jQuery selectors help you to select and manipulate HTML Elements. They are :
Q6. What is $() in jQuery?
$() in jQuery a syntax in jQuery which is used to select the Html elements or collection matching elements from DOM.
Example,
$(‘#id’) for selecting element by id $(‘.classname’) for selecting element by class
Q7. What is jQuery Ajax?
AJAX stands for (Asynchronous JavaScript and XML). It is a process of exchanging data with a server and refreshing the whole page and updating applied changes without reloading the whole page.
jQuery ajax() method helps to send asynchronous HTTP requests to the server.
Q8. Explain width() vs css('width') in JQuery?
JQuery has two ways to set the width of an element. You can set either using CSS or jQuery methods. The main difference is in datatype. In the CSS method, you need to append 'px' to the width value and with "width" you don’t need to specify. CSS method returns string value while width returns an integer value.
For manipulation purposes, the width function is the best option.
Q9. What is the use of param() method in JQuery?
Param() method in jquery creates a serialized representation of an array or an object from element values. The object stands for an array or a plain object or an object to serialize. Traditional has type Boolean indicating to perform a traditional "shallow" serialization.
Syntax :
$.param(object,trad)
Q10. Explain bind() vs live() vs delegate() methods in Jquery?
.bind() attaches events to elements that exist or match the selector at the time the call is made i.e will only apply to the items you currently have selected in your jQuery object.
.live() works for existing and future matching elements i.e will apply to all current matching elements, as well as any you might add in the future.
.delegate() method adds one or more event handlers to the specified element.
Q11. What are the various ajax functions available in Jquery ?
The list of methods are :
Q12. What is difference between $(this) and this in jQuery?
$(this) and this refers to the same element. The main difference is in the way they are used. While using this, you can call the DOM method but not jQuery methods.
Whereas, while using $(this), you can call jQuery methods on it, but not DOM methods.
Q13. Please explain .empty() vs .remove() vs .detach() in Jquery?
empty() – This method removes all content and child elements from the selected element and does not remove the selected elements.
remove() – This method removes all child elements with selected elements and also you can restore all data but not event handlers of removed elements from the DOM. All data and events related to elements will be removed.
detach() – This method removes all child elements with selected elements. Even though it keeps all data and event handlers of the removed elements it is preferred to remove elements but it keeps a copy of the removed elements which can be reused later.
Q14. List some effects methods used in jQuery?
Some of the methods used in jQuery to provide effects are :
Q15. What is the use of toggle() method in JQuery?
The jQuery toggle() is a type of method which is used to toggle between two or more functions such as hide() & show() method
Q16. What is the use of css() method in JQuery?
Css() method in jQuery is used to set or return style properties of one or more style for the selected elements. It is an easy way to get the computed style properties for the elements in the set of matched elements.
Q17. What is jQuery connect?
jQuery is a plugin that is used to connect or bind a function to another function. It is more of assigning a handler for another function. It is used to execute a function when a function from another plugin is executed.
Q18. What is a CDN?
CDN stands for a (Content Delivery Network). It is a system of computers with scripts and other content on them that are widely used by many web pages. It can be a very effective way to speed up a web page
Q19. What is a use of jQuery filter?
The jQuery filter() method returns elements that match a certain criterion. The filter () method can construct a new jQuery object from a subset of the matching elements. The required criteria are matched against each element. Elements that do not match the supplied criteria are removed from the selection and those that match are returned.
Q20. What is ID and class selector in jQuery?
The ID and class selector in jQuery helps to find and select DOM elements easily. The class selector is used in case we need to select multiple elements, which have the same CSS class. Searching and finding HTML elements using selectors are natural and very easy.
Q21. What is use of use of serialize() method in JQuery?
Serialize() method serializes a set of input elements into a string of data. It creates a URL encoded text string by serializing form values. The serialized values can be used in the URL query string while making an AJAX request.
Syntax : $(selector).serialize()
Q22. How to stop event propogation in Jquery?
Event.stopPropogation() is used for stopping event propagation. It prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. You can use the event.isPropagationStopped() method to check whether this method was called for the event.
Syntax : event.stopPropagation()
Q23. What is use of the animate() method in jQuery?
The animate() method performs custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually to create an animated effect.
Syntax : (selector).animate({styles},speed,easing,callback)
The speed parameter specifies the duration of the effect.
The callback parameter is a function to be executed after the animation completes.
Q24. How to read, write and delete cookies in jQuery?
In jQuery, reading, writing and deleting cookies are done by using dough cookie plugin.
The syntax for reading cookie :
$.dough(“cookie_name”);
The syntax for writing cookie :
$.dough(“cookie_name”,”cookie_value”);
The syntax for deleting cookies :
$.dough(“cookie_name”,”remove”)
Q25. What is jQuery UI?
jQuery UI is a set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. jQuery UI is the perfect choice for building highly interactive web applications and to add a date picker to a form of control.
It contains many widgets that maintain state and therefore have a slightly different usage pattern than typical jQuery plugins. All of jQuery UI's widgets use the same patterns, so if you learn how to use one, then you'll know how to use all of them.
Q26. What is use of slice() method in jQuery?
The slice() method reduces the set of matched elements to a subset specified by a range of indices.
Syntax : .slice(start[,end])
A start has a type integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set.
The end has a type integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set.
Q27. How to select all elements in jQuery?
Different selectors can be used to select the required element or even a class of elements.
jQuery selectors allow a user to select and manipulate HTML element(s).
The selection or finding of HTML elements can be based on their name, id, classes, type, attributes, values of attributes and many others.
All selectors in jQuery start with a $() dollar sign.
For example, User can select all elements on a page as following: $("a")
Q28. How to set and get the value of an element using jQuery?
To set any form value of an element using jQuery val() function is to be used.
Here is a demonstration of how to set content with the jQuery val() methods:
$(“#btn”).click(function(){ $(“#test”).val(“hello”); });
This jQuery method also comes with a get/return/callback function. The callback function has two parameters: the index of the current element and the original (old) value. A user then returns the string they wish to use as the new value from the function.
Q29. What is use of $(document).ready()?
A page to be manipulated safely needs the document to be ready. jQuery detects this state of readiness for you. A page document object model (DOM) which is ready for javascript code to execute includes inside $(document).ready(). Code included inside $(window).on("oad",function(){…}) will run once the entire page, not just the DOM, is ready. A developer sometimes can use the shortform $() for $(document).ready().
Example: chaining together the css(), slideup() and slidedown() methods – $("#A1").css("colour","pink").slideup(200).slidedown(200);
Q30. What is chaining in jQuery?
jQuery allows users to chain together actions/methods. Chaining allows users to run multiple jQuery methods within a single statement. This technique of chaining allows us to run multiple jQuery commands, one after the other, on the same elements.
This helps browsers by reducing the time to find the same element more than once. A chain an action user appends the action to the previous action.
Q31. How to get attribute of an element in jQuery?
c
The following example uses how to get the value of the href attribute in a page:
$(“button”).click(function(){ Alert($(“#w3s”).attr(“href”)); });
Q32. What is the jQuery Unbind() method?
The unbind() method removes event handlers from selected elements. The unbind() function removes all or selected event handlers, or stops specific functions from running when the event occurs. This is used to unbind an event from within itself.
This method works on any event handler attached to jQuery.
$(selector).unbind(event,function,eventObj)
Q33. What is $.each() function do in jQuery?
This function can be used to seamlessly iterate over both objects and arrays. An object with a length property is iterated by a numeric index from 0 to 1. The $.each() function is different from the $(selector).each() which is used to iterate over a jQuery object.
For example:
$.each([50,9],function(index, value){ Alert(index + “:” +value); }); This produces two messages: 0: 50 1: 9
Q34. Which is fastest and slowest selector in jQuery?
In jQuery, there are mainly three selectors, which are ID, class, and attribute. Among these, Id selector is the fastest of all, the reason being that ID is supposed to be unique, so the searching stops after ID is found on the Document object model. Whereas, class and attribute search through the entire page to find the required match taking a bit longer then ID selector.
Q35. What is the use of jQuery.data() method?
The data() method gives the user the ability to attached data to or gets data from, within DOM nodes and Javascript objects. When a user uses the data method, the user needs to pass two parameters such as key and a value to be stored.
For example, $(“mydiv”).data({“name”:”pooja”,”age”:24});
Today, the whole world is embracing the jQuery, companies such as IBM, Microsoft and Google are already using it. jQuery open source project is also running for adding more features in the library. This shows that jQuery will run for a long time. To know completely about jQuery, check our jQuery online interview questions. These interview questions will help you to clear all your doubts and to crack any interviews. Get a look!
jQuery | DOJO |
It is a JavaScript library It is a JavaScript toolkit. JQuery is licensed by MIT. The dojo is licensed by BSD or AF. It was started at Rochester Institute of Technology in January 2006 by John Resig. | It was released in 2004 by Dylan Schiemann, David Schontzler and Alex Russell. |
JQuery presents User Interface libraries with many beneficial functionalities | Dojo toolkit provides the features of a widget toolkit. |
JQuery is used mostly for web application and dynamic web pages. | Dojo is used for web-oriented software on desktop, mobile and internet applications. |
JQuery is being used by WordPress, BackBone, Wikipedia, etc. | Dojo is being used by internet browsers like Internet Explorer, Google Chrome, Safari, etc. |
JQuery is lightweight with 19K compressed base libraries. | Dojo provides many customizing choices but it is a massive and complex toolkit. |
JQuery requires a less network bandwidth than Dojo. | Dojo requires a higher network bandwidth than JQuery. |
Valid name is required.
Valid name is required.
Valid email id is required.
Sharad Jaiswal
Sharad Jaiswal is Sr. Web Developer from Noida area. He have rich experience in PHP, Angular Js, React, javascript and Node .If you any query or project on these programming you can drop your enquiry in comment section.