Skip to content

Commit

Permalink
remove bad advice to use .attr() method
Browse files Browse the repository at this point in the history
  • Loading branch information
rmurphey committed Nov 25, 2012
1 parent 3fb611d commit 530b7ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
Expand Up @@ -3,24 +3,12 @@ title: How do I check/uncheck a checkbox input or radio button?
source: http://docs.jquery.com/Frequently_Asked_Questions
---

There are two ways to check/uncheck a checkbox/radio button.

Set the 'checked' attribute to true or false.

```
// Check #x
$("#x").attr( "checked", true );
// Uncheck #x
$("#x").attr( "checked", false );
```

Add or remove the 'checked' attribute:
You can check or uncheck a checkbox element or a radio button using the `.prop()` method:

```
// Check #x
$("#x").attr( "checked", "checked" );
$("#x").prop( "checked", true );
// Uncheck #x
$("#x").removeAttr("checked");
$("#x").prop( "checked", false );
```
Expand Up @@ -3,24 +3,12 @@ title: How do I disable/enable a form element?
source: http://docs.jquery.com/Frequently_Asked_Questions
---

There are two ways to disable/enable form elements.

Set the 'disabled' attribute to true or false:

```
// Disable #x
$("#x").attr( "disabled", true );
// Enable #x
$("#x").attr( "disabled", false );
```

Add or remove the 'disabled' attribute:
You can enable or disable a form element using the `.prop()` method:

```
// Disable #x
$("#x").attr( "disabled", "disabled" );
$("#x").prop( "disabled", true );
// Enable #x
$("#x").removeAttr("disabled");
$("#x").prop( "disabled", false );
```

0 comments on commit 530b7ca

Please sign in to comment.