更大的无线电选择区域 [英] Greater area for radio selection

查看:33
本文介绍了更大的无线电选择区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<span>
   <img src="img/icon.png" alt="" />
   <label><input type="radio" name="" /> Label here</label>
</span>

我希望整个 <span> 都是可点击的,而不仅仅是无线电输入.我如何用 jQuery 做到这一点?

I want the whole <span> to be clickable, not just the radio input. How do I do it with jQuery?

推荐答案

这是一个更好的方法.

$('span').click(function() {
    $(this).find('input').attr({checked:"checked"});
});

请记住,您正在向所有跨度添加点击事件.最好在跨度上有一个类并引用它.

Just keep in mind that you are adding a click event to all spans. Better would be to have a class on the span and reference that.

$('.myClickySpan')...

<span class='myClickySpan'>...

这篇关于更大的无线电选择区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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