score:5

Just use the tagName property:

svg.select("." + STYLE.selected)
   .call( function(){

      switch( selectedElement.tagName.toLowerCase() ) {
        case 'circle': 
          alert("here circle");
          this.style("fill", function(){return d3.rgb(d3.select(this).attr("fill"));});
          break;

        case 'path':
          alert("here path");
          appendMarkerm( this, false );
          break;
      }

    });

EDIT

d3js' select() does not return the element itself, but a d3js wrapper for it (very much like in jQuery, e.g.). So the easiest way, would be to use the call() method to apply a function to all matches (in the case of just select() this is just one).


Related Query