gpt4 book ai didi

Jquery获取RadioButton添加的属性值

转载 作者:行者123 更新时间:2023-12-01 03:46:31 25 4
gpt4 key购买 nike

我现在遇到一个让我抓狂的问题。在我的网页上,我有一个 RadioButton,并向其添加属性,如下所示:

in ...asp

<div id="radio" class="C_Radio">
<asp:RadioButton id="rad1" GroupName="typeSelect" runat="server" />
<asp:RadioButton id="rad2" GroupName="typeSelect" runat="server" />
</div>

in ...asp.vb

rad1.Attributes.Add("rad1", "10") 
rad2.Attributes.Add("rad2", "20")

in fireBug I see this:

<div class="C_Radio" id="radio">
<span rad1="10">
<span rad2="20">

所以值就在那里,但我无法取回它们。

I tryed the following in JQuery

var test;

test = $("#radio input:checked + label").text(); //label of radioButton
test = $("#radio input:checked").val(); //id of selected radioButton
test = $(test); //undefined
test = $(test).val(); //undefined
test = $(test).attr(); //undefined
test = $(test).attr("test"); //undefined
test = $(test).attr("value"); //id of selected radioButton
test = $("rad1").val(); //undefined
test = $("rad1").attr(); //undefined
test = $("#radio").attr("rad1"); //undefined
test = $("#radio input:checked").attr("rad1"); //undefined
test = $("input[name='radio']:checked").val(); //undefined
test = $("input[name='rad1']:checked").val(); //undefined

有人可以帮我吗?我可以用我知道的其他方式做到这一点,但我想解决这个问题。

最佳答案

这个案例是这样解决的:

test = $("#rad1").parent().attr("rad1");  //Result 10
test = $("#rad2").parent().attr("rad2"); //Result 20

关于Jquery获取RadioButton添加的属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13285173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com