Change class of one element when hover over another element d3

后端 未结 1 891
温柔的废话
温柔的废话 2021-01-16 19:05

I have a list of images and a list of image titles. I want to be able to show a hover state (change css) for the title when I mouse over its corresponding image, but I canno

1条回答
  •  Happy的楠姐
    2021-01-16 19:26

    The quick and dirty solution would be to simply use the index of the data element to figure out which title matches which image:

    d3.selectAll(".Myimages")
          .on("mouseover", function(d, i) { 
            d3.select("#PaintingDetails")
              .selectAll("li")
              .classed("selected", function(e, j) { return j == i; })
             });
    

    0 讨论(0)
提交回复
热议问题