我有一个让我疯狂的问题。在我的网页上,我有一个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")
fireBug中的我看到了这一点:
<div class="C_Radio" id="radio">
<span rad1="10">
<span rad2="20">
因此价值观存在,但我无法取回它们。
我在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
有人能帮帮我吗?我可以通过我知道的其他方式来做,但我想解决这个问题。
答案 0 :(得分:3)
这种情况就这样解决了:
test = $("#rad1").parent().attr("rad1"); //Result 10
test = $("#rad2").parent().attr("rad2"); //Result 20