Get bounding box for SVG path using jQuery

前端 未结 5 1626
北荒
北荒 2020-12-16 17:22

I want to get the getBBox() for svg path in jquery. i tried like this

$(\"#\"+ path id)[0].getBBox() -> returns x=0,y=0,width=0,height=0

5条回答
  •  悲&欢浪女
    2020-12-16 17:36

    Try Element.getBoundingClientRect(). It's from the html DOM, but works for me on SVG elements (without much transformation).

提交回复
热议问题