jQuery - Raphael - SVG - selector based on custom data

前端 未结 2 1263
渐次进展
渐次进展 2021-01-20 05:36

I have assigned a custom data attribute to some circles added to the Raphael canvas as follows in a each() loop:

marker.data(\'transaction\', tr         


        
2条回答
  •  日久生厌
    2021-01-20 06:37

    Being that Raphael must support VML, it doesn't keep data in the DOM as is normal with html5 applications. If you want to store data in the dom you must access the html node and set the attribute there...

    marker.node.setAttribute('data-transaction', transaction);
    

    Then you can then query the elements with querySelectorAll. Keep in mind this will fail on < IE8.

    If you want to keep older IE support I'd recommend writing a function that iterates over your markers and returns the Raphael object when mark.data("transaction") == transaction

提交回复
热议问题