使用 jquery 获取选择值和单选值
我有以下一组用于无线电和选择框的 html,我想获取用逗号分隔的值
FOR RADIO BUTTON
<div class="element" id="radio_gender">
<div class="fleft">
<label for="gender">Gender</label>
</div>
<div class="fleft">
<input type="radio" value="Male" name="gender" />Male
<br />
<input type="radio" value=" Female" name="gender" /> Female<br />
</div>
<div class="clr"></div>
</div>
FOR SELECTBOX
<div class="element" id="select_gender2">
<div class="fleft">
<label for="gender2">Gender2</label>
</div>
<div class="fleft">
<select name="gender2" id="gender2" >
<option value="Male">Male</option>
<option value=" Female"> Female</option>
</select>
</div>
<div class="clr"></div>
</div>
对于上述情况我需要一个字符串比如男、女
I have the following set of html for both radio and select box i want to get the value with comma seperated
FOR RADIO BUTTON
<div class="element" id="radio_gender">
<div class="fleft">
<label for="gender">Gender</label>
</div>
<div class="fleft">
<input type="radio" value="Male" name="gender" />Male
<br />
<input type="radio" value=" Female" name="gender" /> Female<br />
</div>
<div class="clr"></div>
</div>
FOR SELECTBOX
<div class="element" id="select_gender2">
<div class="fleft">
<label for="gender2">Gender2</label>
</div>
<div class="fleft">
<select name="gender2" id="gender2" >
<option value="Male">Male</option>
<option value=" Female"> Female</option>
</select>
</div>
<div class="clr"></div>
</div>
for bothe the above case i need a string like Male, Female
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于单选按钮:
对于选择框:
编辑:给出以下评论(对照 jquery 文档进行检查,对最初的错误感到抱歉),尝试 -
并
For the radio button:
For the select box:
EDIT: Given the below comments (which check out against the jquery docs, sorry about the initial mistake), try -
and
如何获取选中的单选按钮值?
How to get checked radio button value?