Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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在SVG中添加图像:<;图像/>;标签变为<;img/>;_Jquery_Svg - Fatal编程技术网

无法通过jQuery在SVG中添加图像:<;图像/>;标签变为<;img/>;

无法通过jQuery在SVG中添加图像:<;图像/>;标签变为<;img/>;,jquery,svg,Jquery,Svg,我想通过jQuery在SVG中添加项。 我可以很好地插入标签,如或,但我不能插入带有标签的图像 此标记自动变为,无法在SVG中显示图像: 我怎样才能防止这种情况? 如果不可能,是否有其他方法可以使用JavaScript/jQuery在SVG中插入图像。jQuery本身无法正确处理SVG操作。您可能应该使用,或者上面链接中描述的一种黑客方法。您应该使用createElements(): 尝试使用我的jQuery hack[[1]: var img = document.createElement

我想通过jQuery在SVG中添加项。 我可以很好地插入标签,如
,但我不能插入带有标签的图像

此标记自动变为
,无法在SVG中显示图像:

我怎样才能防止这种情况?
如果不可能,是否有其他方法可以使用JavaScript/jQuery在SVG中插入图像。

jQuery本身无法正确处理SVG操作。您可能应该使用,或者上面链接中描述的一种黑客方法。

您应该使用
createElements()

尝试使用我的jQuery hack[[1]:
var img = document.createElementNS('http://www.w3.org/2000/svg','image');
img.setAttributeNS(null,'height','536');
img.setAttributeNS(null,'width','536');
img.setAttributeNS('http://www.w3.org/1999/xlink','href','https://upload.wikimedia.org/wikipedia/commons/2/22/SVG_Simple_Logo.svg');
img.setAttributeNS(null,'x','10');
img.setAttributeNS(null,'y','10');
img.setAttributeNS(null, 'visibility', 'visible');
$('svg').append(img);