Skip to content

Commit 45a34b5

Browse files
mikeabdullahscottgonzalez
authored andcommitted
Refer to "headings" not "headers"
1 parent 966bb58 commit 45a34b5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

page/using-jquery-core/jquery-object.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,48 +66,48 @@ When the jQuery function is invoked with a CSS selector, it will return a jQuery
6666
```
6767
// Selecting all <h1> tags.
6868
69-
var headers = $( "h1" );
69+
var headings = $( "h1" );
7070
```
7171

72-
`headers` is now a jQuery element containing *all* the `<h1>` tags already on the page. This can be verified by inspecting the `.length` property of `headers`:
72+
`headings` is now a jQuery element containing *all* the `<h1>` tags already on the page. This can be verified by inspecting the `.length` property of `headings`:
7373

7474
```
7575
// Viewing the number of <h1> tags on the page.
7676
77-
var allHeaders = $( "h1" );
77+
var allHeadings = $( "h1" );
7878
79-
alert( allHeaders.length );
79+
alert( allHeadings.length );
8080
```
8181

8282
If the page has more than one `<h1>` tag, this number will be greater than one. If the page has no `<h1>` tags, the `.length` property will be zero. Checking the `.length` property is a common way to ensure that the selector successfully matched one or more elements.
8383

84-
If the goal is to select only the first header element, another step is required. There are a number of ways to accomplish this, but the most straight-forward is the `.eq()` function.
84+
If the goal is to select only the first heading element, another step is required. There are a number of ways to accomplish this, but the most straight-forward is the `.eq()` function.
8585

8686
```
8787
// Selecting only the first <h1> element on the page (in a jQuery object)
8888
89-
var headers = $( "h1" );
89+
var headings = $( "h1" );
9090
91-
var firstHeader = headers.eq( 0 );
91+
var firstHeading = headings.eq( 0 );
9292
```
9393

94-
Now `firstHeader` is a jQuery object containing only the first `<h1>` element on the page. And because `firstHeader` is a jQuery object, it has useful methods like `.html()` and `.after()`. jQuery also has a method named `.get()` which provides a related function. Instead of returning a jQuery-wrapped DOM element, it returns the DOM element itself.
94+
Now `firstHeading` is a jQuery object containing only the first `<h1>` element on the page. And because `firstHeading` is a jQuery object, it has useful methods like `.html()` and `.after()`. jQuery also has a method named `.get()` which provides a related function. Instead of returning a jQuery-wrapped DOM element, it returns the DOM element itself.
9595

9696
```
9797
// Selecting only the first <h1> element on the page.
9898
99-
var firstHeaderElem = $( "h1" ).get( 0 );
99+
var firstHeadingElem = $( "h1" ).get( 0 );
100100
```
101101

102102
Alternatively, because the jQuery object is "array-like," it supports array subscripting via brackets:
103103

104104
```
105105
// Selecting only the first <h1> element on the page (alternate approach).
106106
107-
var firstHeaderElem = $( "h1" )[ 0 ];
107+
var firstHeadingElem = $( "h1" )[ 0 ];
108108
```
109109

110-
In either case, `firstHeaderElem` contains the native DOM element. This means it has DOM properties like `.innerHTML` and methods like `.appendChild()`, but *not* jQuery methods like `.html()` or `.after()`. The `firstHeaderElem` element is more difficult to work with, but there are certain instances that require it. One such instance is making comparisons.
110+
In either case, `firstHeadingElem` contains the native DOM element. This means it has DOM properties like `.innerHTML` and methods like `.appendChild()`, but *not* jQuery methods like `.html()` or `.after()`. The `firstHeadingElem` element is more difficult to work with, but there are certain instances that require it. One such instance is making comparisons.
111111

112112
### Not All jQuery Objects are Created `===`
113113

0 commit comments

Comments
 (0)