Using the CreateElement method, this is the inability to generate SVG dom
You can use the method below to generate
[JS]View Plaincopy
- var svgns = "Http://www.w3.org/2000/svg";
- $.svg = function $svg (tagName) {
- return $ (Document.createelementns (svgns, tagName));
- };
How to determine if a DOM element is an SVG dom
[JS]View Plaincopy
- function Issvg (EL) {
- return el && el.nodetype = = = 1 && (El instanceof window. svgelement)
- }
The last use of SVG to do buttons to adapt to the dynamic change in color requirements, but need to use JS Auto-hide and display. found that the addclass ("Hide") method with jquery could not be written in. I suspect that SVG is not part of the HTML regular DOM element, and then I solved the problem after I wrapped a div in SVG.
In fact, there is a way to use the native JS to add class as follows.
document.getElementById ("SVG"). SetAttribute ("Class", "Hide");
jquery How to create SVG DOM processing