【问题标题】:dynamic radio button value is not working [duplicate]动态单选按钮值不起作用[重复]
【发布时间】:2018-07-10 09:52:48
【问题描述】:

我正在尝试使用以下代码获取单选按钮的值。能否请任何人告诉我以获取所选单选按钮的值。

<input type="radio" name="abc_181508" value="3" /> Reset                                                    
<input type="radio" name="abc_181509" value="1"  /> Approve
<input type="radio" name="abc_181509" value="0"  /> Reject

name 是动态的,它是一个 listID

谢谢

【问题讨论】:

  • 你能发布你的jQuery代码吗?
  • 基础:name 属性应该相同
  • 你的收音机的名字必须和我想的一样。你能发布你的代码吗?
  • I am trying to get the value of the radio button with the following code.->获取选定单选按钮值的代码在哪里?你有没有试过什么?请在您的问题中发表您的努力。

标签: javascript jquery


【解决方案1】:

要获得单个值,您必须使用唯一的名称,例如,

<input type="radio" name="abc" value="3" /> Reset                                                    
<input type="radio" name="abc" value="1"  /> Approve
<input type="radio" name="abc" value="0"  /> Reject

并获得类似的价值,

$('[name="abc"]:checked').val();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2017-11-25
    相关资源
    最近更新 更多