jQuery Selectors are used to find elements in web document. JQuery selectors make easy to find elements or controls.
after find elements we can have entire control on it. it can be single element or an array of elements.
jQuery provides a lot of techniques to find element by using selectors.
we can select elements by tag, id, class, attributes and many more.
First of all you, needs to open any web browser i.e. Chrome, firefox or Internet Explorer.
Moreover, you can test by type $ sign in console panel, an popup dropdown appears automatically, if jQuery reference is added with in selected website.
Press ctrl+l to clear console.
Type any jQuery code
Press Enter to execute jquery.
Press shift+Enter to go into new line without jQuery execution.
1). All (Universal) Selector
Select all elements:
// Returns array of all elements
Get total selected elements.
// Returns number of selected elements
Get first element from selected element array.
// Returns First Element of selected collection.
2). Element Selector
you can select element by tag name.
it will select all input elements <input />.
you can get first element by
3). Class Selector
you can select element by css class name with period (.) sign prefix.
it will select all elements having attribute class="row".
4). ID Selector
you can select element by its id with hash (#) sign prefix.
Since every element have unique id in html document, it will return only element having id = "StudentId"
5). Multiple Selector
you can also select multiple controls by using multiple selector.
$('selector1, selector2, selectorN')
If you have any query or question or topic on which, we might have to write an article for your interest or any kind of suggestion regarding this post, Just feel free to write us, by hit add comment button below or contact via Contact Us form.
Your feedback and suggestions will be highly appreciated. Also try to leave comments from your valid verified email account, so that we can respond you quickly.