Skip to content

Commit be21e32

Browse files
committed
Merge pull request #202 from rmurphey/199_attr_prop_fix
remove bad advice to use .attr() method
2 parents c011c9c + 530b7ca commit be21e32

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

page/using-jquery-core/faq/how-do-i-check-uncheck-a-checkbox-input-or-radio-button.md

+3-15
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@ title: How do I check/uncheck a checkbox input or radio button?
33
source: http://docs.jquery.com/Frequently_Asked_Questions
44
---
55

6-
There are two ways to check/uncheck a checkbox/radio button.
7-
8-
Set the 'checked' attribute to true or false.
9-
10-
```
11-
// Check #x
12-
$("#x").attr( "checked", true );
13-
14-
// Uncheck #x
15-
$("#x").attr( "checked", false );
16-
```
17-
18-
Add or remove the 'checked' attribute:
6+
You can check or uncheck a checkbox element or a radio button using the `.prop()` method:
197

208
```
219
// Check #x
22-
$("#x").attr( "checked", "checked" );
10+
$("#x").prop( "checked", true );
2311
2412
// Uncheck #x
25-
$("#x").removeAttr("checked");
13+
$("#x").prop( "checked", false );
2614
```

page/using-jquery-core/faq/how-do-i-disable-enable-a-form-element.md

+3-15
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@ title: How do I disable/enable a form element?
33
source: http://docs.jquery.com/Frequently_Asked_Questions
44
---
55

6-
There are two ways to disable/enable form elements.
7-
8-
Set the 'disabled' attribute to true or false:
9-
10-
```
11-
// Disable #x
12-
$("#x").attr( "disabled", true );
13-
14-
// Enable #x
15-
$("#x").attr( "disabled", false );
16-
```
17-
18-
Add or remove the 'disabled' attribute:
6+
You can enable or disable a form element using the `.prop()` method:
197

208
```
219
// Disable #x
22-
$("#x").attr( "disabled", "disabled" );
10+
$("#x").prop( "disabled", true );
2311
2412
// Enable #x
25-
$("#x").removeAttr("disabled");
13+
$("#x").prop( "disabled", false );
2614
```

0 commit comments

Comments
 (0)