@@ -5,6 +5,8 @@ title : Selecting Elements
5
5
attribution : jQuery Fundamentals
6
6
---
7
7
## Selecting Elements
8
+ Selecting Elements
9
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
8
10
9
11
The most basic concept of jQuery is to “select some elements and do something with them.”
10
12
jQuery supports most CSS3 selectors, as well as some non-standard selectors.
@@ -51,7 +53,11 @@ Pseudo-selectors
51
53
When you use the : visible and : hidden pseudo-selectors, jQuery tests the actual
52
54
visibility of the element, not its CSS visibility or display — that is, it looks
53
55
to see if the element's physical height and width on the page are both greater than zero.
56
+ <<<<<<< HEAD
54
57
However, this test doesn't work with < ; tr> elements; in this case, jQuery does check
58
+ =======
59
+ However, this test doesn't work with <tr > elements; in this case, jQuery does check
60
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
55
61
the CSS display property, and considers an element hidden if its display property
56
62
is set to none. Elements that have not been added to the DOM will always be
57
63
considered hidden, even if the CSS that would affect them would render them
@@ -66,21 +72,33 @@ For reference, here is the code jQuery uses to determine whether an element is v
66
72
skip = elem.nodeName.toLowerCase() === "tr";
67
73
68
74
// does the element have 0 height, 0 width,
75
+ <<<<<<< HEAD
69
76
// and it's not a < ; tr>?
77
+ =======
78
+ // and it's not a <tr>?
79
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
70
80
return width === 0 && height === 0 && !skip ?
71
81
72
82
// then it must be hidden
73
83
true :
74
84
75
85
// but if it has width and height
86
+ <<<<<<< HEAD
76
87
// and it's not a < ; tr>
88
+ =======
89
+ // and it's not a <tr>
90
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
77
91
width > 0 && height > 0 && !skip ?
78
92
79
93
// then it must be visible
80
94
false :
81
95
82
96
// if we get here, the element has width
97
+ <<<<<<< HEAD
83
98
// and height, but it's also a < ; tr>,
99
+ =======
100
+ // and height, but it's also a <tr>,
101
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
84
102
// so check its display property to
85
103
// decide whether it's hidden
86
104
jQuery.curCSS(elem, "display") === "none";
@@ -105,7 +123,11 @@ jQuery offers many attribute-based selectors, allowing you to make selections
105
123
based on the content of arbitrary attributes using simplified regular expressions.
106
124
107
125
<div class =" example " markdown =" 1 " >
126
+ <<<<<<< HEAD
108
127
// find all < ; a>s whose rel attribute
128
+ =======
129
+ // find all <a>s whose rel attribute
130
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
109
131
// ends with "thinger"
110
132
$("a[rel$='thinger']");
111
133
</div >
@@ -180,7 +202,11 @@ Sometimes you have a selection that contains more than what you're after; in thi
180
202
<div class =" example " markdown =" 1 " >
181
203
Refining selections
182
204
205
+ <<<<<<< HEAD
183
206
$('div.foo').has('p'); // div.foo elements that contain < ; p>'s
207
+ =======
208
+ $('div.foo').has('p'); // div.foo elements that contain <p>'s
209
+ >>>>>>> moved selecting-elements and doc-ready into jquery-basics folder try 2
184
210
$('h1').not('.bar'); // h1 elements that don't have a class of bar
185
211
$('ul li').filter('.current'); // unordered list items with class of current
186
212
$('ul li').first(); // just the first unordered list item
@@ -239,4 +265,4 @@ Selects inputs with type="text"
239
265
Using form-related pseduo-selectors
240
266
241
267
$('#myForm :input'); // get all elements that accept input
242
- </div >
268
+ </div >
0 commit comments