Why the <image> tag was changed by the <img> jquery tag in chrome

I am using jquery to manage SVG files in chrome,

$('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>"); 

but I open development tools, it looks like:

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

How to deal with it?

+4
source share
1 answer

This is not jQuery; this is a Chrome implementation in the DOM. Try the following:

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

From Chrome, Firefox, and Opera, it seems that only Chrome does this. I cannot find any reference to this behavior in several standards that I checked. If you want Chrome to create an image tag, you may need to explicitly specify it in the right namespace using document.createElementNS . I do not know how you will get jQuery for this.

+5
source

Source: https://habr.com/ru/post/1493992/


All Articles