onclick不适用于少数锚标签

时间:2014-09-15 11:58:37

标签: javascript

我有几个相同的锚标签。但其中一个没有按预期工作。

我托管了内容here

任何帮助将不胜感激

修改 - 添加了要提问的代码:

<a onclick="alert(1)" style="text-decoration: underline;">111</a>
<a onclick="alert(1)" style="text-decoration: underline;">111</a>
<a onclick="alert(1)" style="text-decoration: underline;">111</a>
<a onclick="alert(1) " style=" text-decoration: underline;">111</a>
<a onclick="alert(1)" style="text-decoration: underline;">111</a>

这些空格实际上代表了某种非打印角色,最终成为了操作问题的根源。

1 个答案:

答案 0 :(得分:0)

在HTML行中有一些奇怪的隐藏字符。具体而言,在"的结束onclick之前和"的开放style之后。

如果使用右箭头键移动HTML行,则可以对它们进行细化。

这是您的HTML粘贴到一个简单的文字处理器:

<a onclick="alert(1)" style="text-decoration: underline;">111</a>
<a onclick="alert(1)" style="text-decoration: underline;">111</a>
<a onclick="alert(1)" style="text-decoration: underline;">111</a>
<a onclick="alert(1) " style=" text-decoration: underline;">111</a>
<a onclick="alert(1)" style="text-decoration: underline;">111</a>
相关问题