0

I think my approach here is off.

I had code that worked:

$('.rectangle').mouseenter(function () {
     var rect = d3.select("#"+this.id)
     rect.transition()
         .duration(500)
         .attr("width", 40)
         .attr("height", 400);
       });

Then, I added a second id to each element, and the functionality broke. I've tried various ways of selecting an element that has multiple ids, since that seems to be the problem; none of them worked. This post has suggestions that seem to work for multiple classnames, but these approaches don't work for multiple ids.

I'd thought that adding the second id was cleaner code, but and then I had to add a second id to each d3 element so that each one could be selected by either unique property - word or element number.

Is there a way in d3 to select an element that has multiple ids?

Community
  • 1
  • 1
fstopzero
  • 1,073
  • 2
  • 10
  • 24

1 Answers1

2

Short answer: no.

Long answer: You can't have multiple IDs for an element -- by definition, an ID is a unique identifier for an element (see this question). You can achieve the same functionality by assigning multiple classes (just add classes instead of IDs).

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204