Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery IE7 Id追加问题_Jquery_Css - Fatal编程技术网

Jquery IE7 Id追加问题

Jquery IE7 Id追加问题,jquery,css,Jquery,Css,所以我有以下Jquery $j("a#Pinterest").html("<img src='/images/Social Media/pinterest.png'>"); $j(“a#Pinterest”).html(“”); 加成如下: <a id="Pinterest"></a> 这很好,但是用户可以选择在一个页面中添加多个,我注意到在IE7中,只有第一个锚点连接了图像,而没有其他锚点。在所有其他浏览器中,它们都会附加图像 有什么想法吗

所以我有以下Jquery

    $j("a#Pinterest").html("<img src='/images/Social Media/pinterest.png'>");
$j(“a#Pinterest”).html(“”);
加成如下:

<a id="Pinterest"></a>

这很好,但是用户可以选择在一个页面中添加多个,我注意到在IE7中,只有第一个锚点连接了图像,而没有其他锚点。在所有其他浏览器中,它们都会附加图像


有什么想法吗?

id
在html页面上必须是唯一的。同一个ID只能使用一次。改用
属性。

HTML

<a class="Pinterest"></a>
<a class="Pinterest"></a>

JS

$j("a.Pinterest").html("<img src='/images/Social Media/pinterest.png'>");
$j(“a.Pinterest”).html(“”);

Id应该是唯一的,但您可以对使用相同类名的一组元素使用class。

页面中是否有“”的多个副本?是的,这就是我所暗示的。:)