Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get checked radio buttons value in jQuery mobile?
    text
    copied!<p>I have a set of radio button groups. How can I get which is checked yes or now for each group and add them to array?</p> <p>Here is what I came up so far:</p> <p>My jquery code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { $("#getinfo").click(function () { $("input[name*=radio-choice-1]:checked").each(function () { alert($(this).val()); }); }); }); &lt;/script&gt; </code></pre> <p>and radio buttons</p> <pre><code>&lt;fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain"&gt; &lt;input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" /&gt; &lt;label for="radio-choice-1"&gt;Yes&lt;/label&gt; &lt;input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2" /&gt; &lt;label for="radio-choice-2"&gt;No&lt;/label&gt; &lt;/fieldset&gt; &lt;fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain"&gt; &lt;input type="radio" name="radio-choice-3" id="radio-choice-3" value="choice-3" /&gt; &lt;label for="radio-choice-3"&gt;Yes&lt;/label&gt; &lt;input type="radio" name="radio-choice-3" id="radio-choice-4" value="choice-4" /&gt; &lt;label for="radio-choice-4"&gt;No&lt;/label&gt; &lt;/fieldset&gt; &lt;fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain"&gt; &lt;input type="radio" name="radio-choice-5" id="radio-choice-5" value="choice-5" /&gt; &lt;label for="radio-choice-5"&gt;Yes&lt;/label&gt; &lt;input type="radio" name="radio-choice-5" id="radio-choice-6" value="choice-6" /&gt; &lt;label for="radio-choice-6"&gt;No&lt;/label&gt; &lt;/fieldset&gt; &lt;fieldset data-role="controlgroup" data-type="horizontal" data-role="fieldcontain"&gt; &lt;input type="radio" name="radio-choice-7" id="radio-choice-7" value="choice-7" /&gt; &lt;label for="radio-choice-7"&gt;Yes&lt;/label&gt; &lt;input type="radio" name="radio-choice-7" id="radio-choice-8" value="choice-8" /&gt; &lt;label for="radio-choice-8"&gt;No&lt;/label&gt; &lt;/fieldset&gt; &lt;a href="#" id="getinfo"&gt;getinfo&lt;/a&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload