使单选按钮可点击链接 [英] Make Radio Button Clickable Link

查看:97
本文介绍了使单选按钮可点击链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个链接,里面有一个单选按钮,我想制作一个可点击的链接。我试过了:

I have a link that holds a radio button, which I want to make a clickable link. I've tried:

<a href="/">
  <input type="radio" style="pointer-events:none;">
</a>

这可以防止单击单选按钮时发生的任何事情。我希望它遵循链接。任何想法?

This prevents anything from happening when I click the radio button. I would like it to follow the link. Any ideas?

http://css-tricks.com/almanac/properties/p/pointer-events/

推荐答案

您可以使用JavaScript将这样的元素变成链接。例如:

You can use JavaScript to turn elements like that into a link. E.g.:

<input type="radio" onclick="window.location='/';" />

如果其他元素应该与单选按钮链接在一起,请将 onclick 在wrapper元素上的属性。

If other elements should be combined on the link with the radio button, put the onclick attribute on the wrapping element.

这篇关于使单选按钮可点击链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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