Javascript 单击标签不会选中ie8/9中的单选框
我们遇到了一个导致IE 8和IE 9出现问题的问题。单击标签后,应选中收音机框。这在除IE8/9之外的所有浏览器中都很好,IE8/9不检查单选按钮Javascript 单击标签不会选中ie8/9中的单选框,javascript,jquery,html,internet-explorer,internet-explorer-9,Javascript,Jquery,Html,Internet Explorer,Internet Explorer 9,我们遇到了一个导致IE 8和IE 9出现问题的问题。单击标签后,应选中收音机框。这在除IE8/9之外的所有浏览器中都很好,IE8/9不检查单选按钮 <label for="so100"> <img alt="" src="images/type6img.jpg" class="anitem1pic"> <input type=radio value=1 name="site" id="so100" /> <span class="
<label for="so100">
<img alt="" src="images/type6img.jpg" class="anitem1pic">
<input type=radio value=1 name="site" id="so100" />
<span class="anitem1">Stag</span>
</label>
雄鹿
包装图像不会触发收音机
在中,文本起作用,图像不:
这是一份有建议的复制件
下面是基于的测试解决方案。文章中的解决方案破坏了Chrome。我在条件注释中的包装可以防止脚本破坏在单击时触发的浏览器。如果IE9和10像Chrome一样工作,则可以将IE更改为IE8
也不起作用,因为这是IE抱怨的图像
<label for="so100">
<img alt="" src="http://lorempixel.com/output/abstract-q-c-50-50-8.jpg" class="anitem1pic">
</label>
<input type=radio value=1 name="site" id="so100" />
<label for="so100">
<span class="anitem1">Stag</span>
</label>
雄鹿
使用背景图像将起作用,但是您应该使用这种方式,并且这种方式适用于所有浏览器:
<label for="radio1"> Option 1 </label>
<input type="radio " id="radio1" name= "option" />
<label for="radio2"> Option 2 </label>
<input type="radio " id="radio2" name= "option" />
选项1
选择2
您的单选按钮应该是您的标签的子按钮吗?因为它应该是它的兄弟姐妹,而不是孩子我无法复制你的问题working@mplungjan我发现很难理解,从语法上来说,为什么你会把单选按钮作为标签的一部分?另外,在我的IE9中,当我单击图像时,它不会选中单选按钮。@RGraham-解决方案是不换行。我从来没有。参见我的答案谢谢你的解决方案,但它似乎在ie 8/9中不起作用参见我最新更新中的解决方案,但他希望有两个触发器。除IE中的图像外,标签中的包装也适用。
<label for="radio1"> Option 1 </label>
<input type="radio " id="radio1" name= "option" />
<label for="radio2"> Option 2 </label>
<input type="radio " id="radio2" name= "option" />