Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在追加文本之前找到SVG文本位置_Javascript_Jquery_Html_Svg - Fatal编程技术网

Javascript 如何在追加文本之前找到SVG文本位置

Javascript 如何在追加文本之前找到SVG文本位置,javascript,jquery,html,svg,Javascript,Jquery,Html,Svg,这是我的密码 <html> <body> <svg id="text" height="400" width="400"> <text transform="rotate(127,128,64)" opacity="1" text-anchor="start" font-weight="regular" font-style="Normal" font-family="Segoe UI" font-size="12px

这是我的密码

<html>
   <body>
      <svg id="text" height="400" width="400">
         <text transform="rotate(127,128,64)" opacity="1" text-anchor="start" font-weight="regular" font-style="Normal" font-family="Segoe UI" font-size="12px" fill="#191919" y="68.25" x="128" id="caption">Revenue </text>
      </div>
  </body>
</html)

但是,在追加文本之前,我需要相同的输出。

为什么需要这样做?我需要检查它是否与其他div重叠(svg或超出区域)。如果是重叠,则需要执行修剪操作(修订版…)否,我的意思是,为什么需要按照与工作顺序相反的顺序进行操作,即追加文本,然后找到位置,然后修剪它。
var pos = document.getElementById("text").getStartPositionOfChar(6);
var matrix = document.getElementById("text").transform.animVal.getItem(0).matrix;
var position = pos.matrixTransform(matrix);
alert(position.x + ", " + position.y);