Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 9bbc8dc

Browse files
Docs (forms): Added info about hiding labels accessibly in case of radio buttons and checkboxes.
1 parent 48cea62 commit 9bbc8dc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/forms/docs-forms.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,27 @@ <h2>Hiding labels accessibly</h2>
8181

8282
<p>While the label will no longer be visible, it will be available to assisitive technologies such as screen readers.</p>
8383

84+
<p>Because radio and checkbox buttons use the <code>label</code> to display the button text you can't use <code>ui-hidden-accessible</code> in this case. However, the class <code>ui-hide-label</code> can be used to hide the legend element:</p>
85+
86+
<pre><code>
87+
&lt;div data-role=&quot;fieldcontain&quot; class=&quot;ui-hide-label&quot;&gt;
88+
<strong>&lt;fieldset data-role=&quot;controlgroup&quot;&gt;
89+
&lt;legend&gt;Agree to the terms:&lt;/legend&gt;</strong>
90+
&lt;input type=&quot;checkbox&quot; name=&quot;checkbox-2a&quot; id=&quot;checkbox-2a&quot; class=&quot;custom&quot; /&gt;
91+
&lt;label for=&quot;checkbox-2a&quot;&gt;I agree&lt;/label&gt;
92+
<strong>&lt;/fieldset&gt;</strong>
93+
&lt;/div&gt;
94+
</code></pre>
95+
96+
<div data-role="fieldcontain" class="ui-hide-label">
97+
<fieldset data-role="controlgroup">
98+
<legend>Agree to the terms:</legend>
99+
<input type="checkbox" name="checkbox-2a" id="checkbox-2a" class="custom" />
100+
<label for="checkbox-2a">I agree</label>
101+
</fieldset>
102+
</div>
84103

104+
85105
<h2>Disabling form elements</h2>
86106
<p>All jQuery Mobile widgets can be disabled in the markup by adding the standard <code>disabled</code> attribute to the element, just like you would with native controls. Each form widget also has standard <code>disable</code> and <code>enable</code> methods that are documented with each form widget. Here are a few examples of disabled widgets: </p>
87107

0 commit comments

Comments
 (0)