wie man svg-element Typ

ich habe eine Frage, wie bekomme ich den Typ der svg-element, btw ich nutze d3.js

ich habe sth wie diese

var selectedElement = svg.select("." + STYLE.selected);

         if (selectedElement instanceof SVGCircleElement){
            alert("here circle");
            selectedElement.style("fill", function(){return d3.rgb(d3.select(this).attr("fill"));});
         }
           if (selectedElement instanceof SVGPathElement){
             alert("here path");
                appendMarkerm(selectedElement,false);

         }

aber es scheint nicht funktioniert , kann jemand hier helfen ,danke !!


***finally, i made it work like this*** 

var selectedElement = svg.select("." + STYLE.selected);
           if (selectedElement.node() instanceof SVGCircleElement){
            selectedElement.style("fill", function(){return d3.rgb(d3.select(this).attr("fill"));});
         }
           if (selectedElement.node() instanceof SVGPathElement){
            changeMarkerStyle(selectedElement,false); 
         }

cauz Auswahl.node() wird wieder das erste element der Auswahl

InformationsquelleAutor user2717621 | 2013-08-30
Schreibe einen Kommentar