0

I want to add click event to a d3 circle element that is static. I dynamically loaded this d3 code:

     var svgContainer = d3.select("#vis").append("svg")
                                .attr("width", 200)
                                .attr("height", 200);

    //Draw the Circle
      var circle = svgContainer.append("circle")
                    .attr("class","item")
                    .attr("cx", 30)
                    .attr("cy", 30)
                    .attr("r", 20); 

Somewhere in my code, I want to add the click event to circles that contain a class called "item". I am using following code but it does not work

  $('.item').on('click', function(){
     console.log("click added");
  });

I looked at this post as well but it did not help me.

Bahador Saket
  • 995
  • 1
  • 12
  • 24

0 Answers0