JQuery and SVG - how to find the 'g' tag

前端 未结 2 662
既然无缘
既然无缘 2021-01-12 13:06

Imagine this:


    
    

相关标签:
2条回答
  • 2021-01-12 13:07

    Thanks to C-Link I've solved this.

    To be sure only the nodes are clickable I've wroted:

    $("svg").find("g.node").click(function(){
        alert("Lolol");
    });
    

    And it works fine.

    0 讨论(0)
  • 2021-01-12 13:15

    Use find() method for more info visit this

    For eg $("body").find("p").css("background-color","#f00"); sets all body's <p> element background-color to red.

    For your question try this:

    $("svg").find("g").click(function(){
    
    // your jquery code here
    
    }
    );
    
    0 讨论(0)
提交回复
热议问题