Skip to content

Commit 10209b3

Browse files
committed
Button: Improve accessibility for checkbox/radio buttons
Fixes jquerygh-185 Closes jquerygh-195
1 parent 8964a8b commit 10209b3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

entries/button.xml

+16-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<p>In addition to basic push buttons, radio buttons and checkboxes (inputs of type radio and checkbox) can be converted to buttons. Their associated label is styled to appear as the button, while the underlying input is updated on click. For the association to work properly, give the input an <code>id</code> attribute, and refer to that in the label's <code>for</code> attribute. Don't nest the input inside the label, as that <a href="http://www.paciellogroup.com/blog/2011/07/html5-accessibility-chops-form-control-labeling/">causes accessibility problems</a>.</p>
99

10-
<p>In order to group radio buttons, Button also provides an additional widget, called Buttonset. Buttonset is used by selecting a container element (which contains the radio buttons) and calling <code>.buttonset()</code>. Buttonset will also provide visual grouping, and therefore should be used whenever you have a group of buttons. It works by selecting all descendants and applying <code>.button()</code> to them. You can enable and disable a button set, which will enable and disable all contained buttons. Destroying a button set also calls each button's <code>destroy</code> method.</p>
10+
<p>In order to group radio buttons, Button also provides an additional widget, called Buttonset. Buttonset is used by selecting a container element (which contains the radio buttons) and calling <code>.buttonset()</code>. Buttonset will also provide visual grouping, and therefore should be used whenever you have a group of buttons. It works by selecting all descendants and applying <code>.button()</code> to them. You can enable and disable a button set, which will enable and disable all contained buttons. Destroying a button set also calls each button's <code>destroy</code> method. For grouped radio and checkbox buttons, it's recommended to use a <code>fieldset</code> with a <code>legend</code> to provide an accessible group label.</p>
1111

1212
<p>When using an input of type button, submit or reset, support is limited to plain text labels with no icons.</p>
1313

@@ -90,11 +90,21 @@ $( "button" ).button();
9090
$( "#radio" ).buttonset();
9191
]]></code>
9292
<html><![CDATA[
93-
<div id="radio">
94-
<input type="radio" id="radio1" name="radio"><label for="radio1">Choice 1</label>
95-
<input type="radio" id="radio2" name="radio" checked="checked"><label for="radio2">Choice 2</label>
96-
<input type="radio" id="radio3" name="radio"><label for="radio3">Choice 3</label>
97-
</div>
93+
<form>
94+
<fieldset>
95+
<legend>Favorite jQuery Project</legend>
96+
<div id="radio">
97+
<input type="radio" id="sizzle" name="project">
98+
<label for="sizzle">Sizzle</label>
99+
100+
<input type="radio" id="qunit" name="project" checked="checked">
101+
<label for="qunit">QUnit</label>
102+
103+
<input type="radio" id="color" name="project">
104+
<label for="color">Color</label>
105+
</div>
106+
</fieldset>
107+
</form>
98108
]]></html>
99109
</example>
100110
<category slug="widgets"/>

0 commit comments

Comments
 (0)