Mik*_*ike 6 javascript c# asp.net
我正在使用asp单选按钮组列出表单中的答案.这是结构的一个例子.
<asp:RadioButtonList id="Q2" runat="server">
<asp:ListItem Text="Go to <a target='_blank' href='http:www.google.com'>Google</a>" Value="a"></asp:ListItem>
<asp:ListItem Text="Go to <a target='_blank' href='http:www.yahoo.com'>Yahoo</a>" Value="a"></asp:ListItem>
</asp:RadioButtonList>
Run Code Online (Sandbox Code Playgroud)
所以我希望能够点击链接,而不是选择与之关联的单选按钮.在IE中它工作正常,但在Firefox中,单击链接时将选择单选按钮.我真的不需要标签来实际选择合适的单选按钮,所以有没有办法在javascript或asp或C#代码的某个地方禁用它们?
毫无疑问,它将它们包装在一个label为您提供选择行为的元素中。您可以手动生成代码(我的选择),也可以在客户端使用 javascript 解开它们。
<div>
<input type="radio" name="Q2" id="Q2_google" value="google" /> <a target="_blank" href="http://www.google.com">Google</a>
...
</div>
Run Code Online (Sandbox Code Playgroud)
或客户端
$(function() {
$('label:has(a)').each( function() {
var html = $(this).html();
$(this).replaceWith($(html));
});
});
Run Code Online (Sandbox Code Playgroud)