为什么<图像>标记已更改<img>由jquery标记,在chrome中

why a <image> tag was changed <img> tag by jquery,in chrome

本文关键字:gt lt 标记 jquery chrome 图像 为什么 img      更新时间:2023-09-26

我使用jquery来控制chrome、中的SVG文件

$('svg #lotsofimage').append("<image xlink:href='" + conf[thing].base + "' width= '" + conf[thing].width + "px' height= '" + conf[thing].height + "px' x='" + thing_x + "pt' y='" + thing_y + "pt' ></image>");

但我打开开发工具,它显示为:

<img xlink:href="xxxx" width="xxxx">
<image></image>was instead of <img />

如何处理?

它不是jQuery;这是Chrome对DOM的实现。试试这个:

> document.createElement('image').tagName
'IMG'

在Chrome、Firefox和Opera之外,似乎只有Chrome能做到这一点。在我检查的一些标准中,我找不到任何关于这种行为的参考。如果您希望Chrome创建一个image标记,您可能需要使用document.createElementNS显式地将其放在正确的命名空间中。我不知道你怎么会让jQuery这么做。