Here are a few Jquery interview questions that will give more insights on it.
What are the core features of jQuery?
jQuery presents the following as its core features −
– Event handling: There’s an elegant way to capture a wide variety of events using jQuery without disturbing the HTML code.
– DOM manipulation − jQuery has eased out activities like selecting DOM elements as well as traversing and modifying them by using a cross-browser open source selector engine.
– AJAX Support − It is capable of providing AJAX compatibility and support to develop a responsive and feature-packed website.
– Animations − There are numerous built-in animation effects in the jQuery framework that can enhance the UI of your websites.
– Cross Browser Support − Supports all web browsers and works well in IE 6.0+, Safari 3.0+, FF 2.0+, Chrome and Opera 9.0+.
– Latest Technology − Supports CSS3 selectors plus the basic XPath syntax.
– Lightweight − The jQuery library is light-weighted in size.
How does jQuery help to ensure whether the DOM is ready?
You can use $(document).ready() function to ensure that. As soon as the DOM loads, everything inside it will load before the loading of page contents.
What is a jQuery selector?
A function that employs expressions to find the matching elements from a DOM as per the criteria is called a jQuery Selector. In simpler words, one or more HTML elements are selected using the jQuery selector. Once an element is picked then, we can execute various operations on it. The jQuery selectors start with a dollar sign and parentheses – $().
How to choose multiple elements using jQuery?
Suppose we want the combined results of all the specified selectors E, F or G, then $(‘E, F, G’) will give us all those elements, where selectors can be any valid jQuery selector.
Which method gets the attributes of an element using jQuery?
The attr() method in jQuery fetches an attribute’s value from the first element in the matched set.
Which method sets the attributes of an element using jQuery?
The attr(name, value) method sets the named attribute with the passed value for all elements in the wrapped set.
How can you apply a style to an element using jQuery?
The addClass( classes ) method in jQuery is responsible for applying styles. When used, it applies defined style sheets upon all the matched components. You can define multiple classes parted by space.