IE doesn't respect <label> within <anchor>

拈花ヽ惹草 提交于 2019-12-11 05:49:04

问题


So I just found out that IE (even the current 10 & 11) do not support labels within anchor tags...but DOES support onclick actions within said tag. Ran into this when I was updating a menu system and wanted to use labels to separate the menu description from the associated shortcut. The 'redirect/processing' modal window comes up fine, but then things just sat there.

<a target="_blank" href="http://www.google.com" onclick="console.log('you clicked me')">
    <label>I am a first label</label>
    <label>Look @ me, I'm second!</label>
</a>

As I dived into this strange topic, I found that the whitespace between the labels behaved appropriately...only when I hovered over the label did my ability to href outta here went away.

So...what's the solution?


回答1:


Use spans...that's it...

<a target="_blank" href="http://www.theonion.com" onclick="console.log('you clicked me')">
    <span>I am another first label</span>
    <span>Look @ me, I'm another second!</span>
</a>

http://jsfiddle.net/bdGPB/1/



来源:https://stackoverflow.com/questions/18854800/ie-doesnt-respect-label-within-anchor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!