-->

28 April 2021

jQuery Selectors

  Asp.Net CS By Example       28 April 2021
jQuery Selectors

 In this post, we are learning about jQuery Selectors. jQuery All HTML elements based on their id, classes, types (text, radio etc.), attributes (id, title, src etc), tag name (div, p, form, table, tr, th, td etc.) etc are jQuery selectors. $("selector") means to access one specified element.

 Below Table lists some selectors. We can refer to this table as needed as we create our own jQuery pages.

Sr.No Selector Description
1)#id Selects a single element with the specified ID.
2)element Selects all elements with the specified name.
3).class Selects all elements with the specified class.
4)* Selects all elements.
5)selector1, selector2, selectorN Selects the combined results of all the selectors.
6)ancestor descendant Selects all descendant elements specified by descendant of elements specified by ancestor.
7)parent > child Selects all direct child elements specified by child of elements specified by parent.
8)previous + next Selects all elements specified by next that are next to elements specified by previous.
9)previous ~ siblings Selects all sibling elements following the previous element that match the siblings selector.
10):first Selects the first selected element in the page.
11):last Selects the last selected element in the page.
12):not(selector) Removes all elements matching the specified selector.
13):even Selects even elements.
14):odd Selects odd elements.
15):eq(index) Selects a single element by its index number.
16):gt(index) Selects all elements with an index number greater than the specified one.
17):lt(index) Selects all elements with an index number less than the specified one.
18):header Selects all elements that are headers, such as h1, h2, and h3.
19):animated Selects all elements that are being animated.
20):contains(text) Selects elements that contain the specified text.
21):empty Selects all elements that have no children.
22):has(selector) Selects elements that contain at least one element that matches the specified selector.
23):parent Selects all elements that are parents.
24):hidden Selects all elements that are hidden.
25):visible Selects all elements that are visible.
26)[attribute] Selects elements that have the specified attribute.
27)[attribute=value] Selects elements that have the specified attribute with the specified value.
28)[attribute!=value] Selects elements that have the specified attribute but not the specified value.
29)[attribute^=value] Selects elements that have the specified attribute and start with the specified value.
30)[attribute$=value] Selects elements that have the specified attribute and end with the specified value.
31)[attribute*=value] Selects elements that have the specified attribute and contain the specified value.
32):nth-child(index/even/odd/equation) Selects elements that are the nth child or that are the parent’s even or odd children.
33):first-child Selects all elements that are the first child of their parents.
34):last-child Selects all elements that are the last child of their parents.
35):input Selects all input elements.
36):text Selects all input elements of type text.
37):radio Selects all input elements of type radio.
38):checkbox Selects all input elements of type checkbox.
39):enabled Selects all elements that are enabled.
40):disabled Selects all elements that are disabled.
41):checked Selects all elements that are checked.
42):selected Selects all elements that are selected.



logoblog

Thanks for reading jQuery Selectors

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.