jquery How to create SVG DOM processing

Source: Internet
Author: User

Using the CreateElement method, this is the inability to generate SVG dom

You can use the method below to generate

[JS]View Plaincopy
    1. var svgns = "Http://www.w3.org/2000/svg";
    2. $.svg = function $svg (tagName) {
    3. return $ (Document.createelementns (svgns, tagName));
    4. };

How to determine if a DOM element is an SVG dom

[JS]View Plaincopy
    1. function Issvg (EL) {
    2. return el && el.nodetype = = = 1 && (El instanceof window. svgelement)
    3. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.