Skip to content

Commit 3992b07

Browse files
author
Connor Cartwright
committed
Changed terminology to set/setting, added example for getting a single attribute
1 parent 88d1fc7 commit 3992b07

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

page/using-jquery-core/manipulating-elements.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,25 @@ The `.attr()` method acts as both a getter and a setter. As a setter, `.attr()`
140140
When the function syntax is used, the function receives two arguments: the zero-based index of the element whose attribute is being changed, and the current value of the attribute being changed.
141141

142142
```
143-
// Manipulating a single attribute.
143+
// Setting a single attribute.
144144
$( "#myDiv a:first" ).attr( "href", "newDestination.html" );
145145
```
146146

147147
```
148-
// Manipulating multiple attributes.
148+
// Getting a single attribute.
149+
$( "a" ).attr( "href" ); // Returns the href for the first a element in the document
150+
```
151+
152+
```
153+
// Setting multiple attributes.
149154
$( "#myDiv a:first" ).attr({
150155
href: "newDestination.html",
151156
rel: "nofollow"
152157
});
153158
```
154159

155160
```
156-
// Using a function to determine an attribute's new value.
161+
// Using a function to set an attribute's new value.
157162
$( "#myDiv a:first" ).attr({
158163
rel: "nofollow",
159164
href: function( idx, href ) {

0 commit comments

Comments
 (0)