From 530b7ca836cafdf52ec1c1012f1ce45cdfb2342a Mon Sep 17 00:00:00 2001 From: Rebecca Murphey Date: Sun, 25 Nov 2012 11:26:03 -0500 Subject: [PATCH] remove bad advice to use .attr() method fix #199 --- ...uncheck-a-checkbox-input-or-radio-button.md | 18 +++--------------- .../how-do-i-disable-enable-a-form-element.md | 18 +++--------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/page/using-jquery-core/faq/how-do-i-check-uncheck-a-checkbox-input-or-radio-button.md b/page/using-jquery-core/faq/how-do-i-check-uncheck-a-checkbox-input-or-radio-button.md index bdf44571..63066159 100644 --- a/page/using-jquery-core/faq/how-do-i-check-uncheck-a-checkbox-input-or-radio-button.md +++ b/page/using-jquery-core/faq/how-do-i-check-uncheck-a-checkbox-input-or-radio-button.md @@ -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 ); ``` \ No newline at end of file diff --git a/page/using-jquery-core/faq/how-do-i-disable-enable-a-form-element.md b/page/using-jquery-core/faq/how-do-i-disable-enable-a-form-element.md index 0b92ba69..02b11096 100644 --- a/page/using-jquery-core/faq/how-do-i-disable-enable-a-form-element.md +++ b/page/using-jquery-core/faq/how-do-i-disable-enable-a-form-element.md @@ -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 ); ``` \ No newline at end of file