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);