简体   繁体   中英

Width of svg polygon tag

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?

你可以得到边界框,这将给你宽度,例如

$('#arrow')[0].getBBox().width;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM