61⟩ What are the types of selectors in jQuery?
There are three types of selectors in jQuery:
► CSS Selector
► XPath Selector
► Custom Selector
“JQuery Programmer Frequently Asked Questions in various JQuery Developer job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting”
There are three types of selectors in jQuery:
► CSS Selector
► XPath Selector
► Custom Selector
Following is the list of important core features supported by jQuery −
► DOM manipulation − The jQuery made it easy to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine called Sizzle.
► Event handling − The jQuery offers an elegant way to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.
► AJAX Support − The jQuery helps you a lot to develop a responsive and feature-rich site using AJAX technology.
► Animations − The jQuery comes with plenty of built-in animation effects which you can use in your websites.
► Lightweight − The jQuery is very lightweight library - about 19KB in size ( Minified and gzipped ).
► Cross Browser Support − The jQuery has cross-browser support, and works well in IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+.
► Latest Technology − The jQuery supports CSS3 selectors and basic XPath syntax.
$('tag-name') selects all element of type tag-name in the document. For example, $('p') selects all paragraphs <p> in the document.
A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria. Simply you can say, 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. jQuery selectors start with the dollar sign and parentheses - $().
The position( ) method gets the top and left position of an element relative to its offset parent.
The removeClass(class) method remove all or the specified class(es) from the set of matched elements.
The factory function $() is a synonym of jQuery() function. So in case you are using any other JavaScript library where $ sign is conflicting with some thing else then you can replace $ sign by jQuery name and you can use function jQuery() instead of $().
The end( ) method reverts the most recent 'destructive' operation, changing the set of matched elements to its previous state.
Yes, we can add more than one document.ready function in a page. But, body.onload can be added once in a page.
The children( [selector]) method gets a set of elements containing all of the unique immediate children of each of the matched set of elements.
Efficiency of web page increases when minimized version of jQuery is used.min.js file will be more than 50% less than the normal js file. Reduction in the file size makes the web page faster.
The prev( [selector] ) method gets a set of elements containing the unique previous siblings of each of the matched set of elements.
jQuery each function is used to loop through each and every element of the target jQuery object. It is also useful for multi element DOM, looping arrays and object properties.
No, jQuery is not a replacement of JavaScript.
The jQuery filter is used to filter the certain values from the object list based on the criteria. Example is to filter certain products from the master list of products in a cart website.
The command $.ui.version returns jQuery UI version.
ID and Element are the fastest selectors in jQuery.
The siblings( [selector] ) method gets a set of elements containing all of the unique siblings of each of the matched set of elements.
The nextAll( [selector] ) finds all sibling elements after the current element.
The addClass( classes ) method can be used to apply defined style sheets onto all the matched elements. You can specify multiple classes separated by space.