如何在广播组中获取所选广播的文本 [英] How Can I get the text of the selected radio in the radio groups

查看:110
本文介绍了如何在广播组中获取所选广播的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如标题中所述 例如:

<input id="User_Type_0" type="radio" name="User_Type" value="1" checked="checked" />
<label for="User_Type_0">User1</label>
<input id="User_Type_1" type="radio" name="User_Type" value="2" />
<label for="User_Type_1">User2</label>

我如何获取文本:用户1

how can I get the text:User 1

推荐答案

$('input:radio:checked').siblings('label:first').html()

更新:

正如Victor在评论部分所指出的那样,前一个选择器将始终选择第一个标签. 下一个函数应该起作用:

As pointed out by Victor in the comments section the previous selector will always select the first label. The next function should work:

$('input:radio:checked').next('label:first').html()

这篇关于如何在广播组中获取所选广播的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆