1

Given this svg polygon:

<polygon class="range_arrow"
     id="arrow"
     points="0,0 5,5 0,10 -5,5"
     data-width="10"/>

I can get the width if I've entered it manually.

$('#arrow').data("width");

However $('#arrow').width(); returns 0 and $('#arrow').attr("width"); returns undefined

Is it possible to get the correct width for a polygon tag?

4

1 回答 1

4

您可以获得边界框,这将为您提供宽度,例如

$('#arrow')[0].getBBox().width;
于 2013-10-22T15:34:57.310 回答