Skip to content

remove bad advice to use .attr() method #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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 );
```
Original file line number Diff line number Diff line change
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 );
```