Retrieving DOM textnode position

后端 未结 6 2073
萌比男神i
萌比男神i 2020-12-30 01:14

Is it possible to retrieve the geometric position (i.e. top/left offsets from either the parent element, the page, etc) of a text node?

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 01:59

    Have a look at this article - it uses the offsetParent property to recursively figure out the offset.

    I would always recommend jquery over rolling your own methods for browser-varying stuff like this. The jquery CSS functions seem to have the methods you need!

提交回复
热议问题