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?

有帮助吗?

解决方案

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/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top