【发布时间】:2012-01-05 01:16:40
【问题描述】:
我的页面上有一些单选按钮可供用户标记(如下)。除了单选按钮之外,还有一个带有 textarea 的“其他”按钮,用于以不同的原因写入。我希望能够查看通过 jquery 提交表单时按下了哪些按钮。我知道如何使用 .post() 但我不确定是否应该在单选按钮的每个 id 上使用 .val() 。或者,是否有一种检查可以检查整个组并获得检查的标签?如果按下另一个按钮,我很确定我可以在 textarea 上使用 .val()。
HTML:
<input type='radio' id='spam' name='flagGroup'></input><label for='spam'>It is spam</label><br>
<input type='radio' id='offTopic' name='flagGroup'></input><label for='offTopic'>It is off topic</label><br>
<input type='radio' id='quality' name='flagGroup'></input><label for='quality'>It does not meet quality standards</label><br>
<input type='radio' id='wrongLocation' name='flagGroup'></input><label for='wrongLocation'>It is in the wrong location</label><br>
<input type='radio' id='duplicate' name='flagGroup'></input><label for='duplicate'>There is a duplicate question</label><br>
<input type='radio' id='other' name='flagGroup'></input><label for='other'>Other:</label><br>
<textarea id='flagOtherTextarea' rows='2' cols='40' wrap='soft'></textarea>
<hr />
<input type='radio' id='mod'></input><label for='mod'>It needs moderator attention</label>
【问题讨论】:
标签: jquery html radio-button