Retrieving DOM textnode position

后端 未结 6 2091
萌比男神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条回答
  •  情深已故
    2020-12-30 02:11

    There isn't any built-in, cross-browser way to do this. I would use jQuery with the Dimensions plugin: http://brandonaaron.net/docs/dimensions/

    It is cross-browser and will give you height, width and x & y offsets, among others.

提交回复
热议问题