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

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

问题描述

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

我想要整个< span> 可点击,而不仅仅是无线电输入。

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"});
});

请注意,您要将点击事件添加到所有跨度 。更好的是在span和引用上有一个类。

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天全站免登陆