131
rated 0 times
[
135]
[
4]
/ answers: 1 / hits: 18971
/ 9 Years ago, thu, september 10, 2015, 12:00:00
I have a very simple svg with just one line on it
<svg version=1.1 id=animation xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink viewBox=0 0 640 480 xml:space=preserve preserveAspectRatio=xMinYMin meet baseProfile=tiny>
<line id=line-1 style=stroke:#777777;stroke-miterlimit:10; x1=358 y1=332.5 x2=371.3 y2=364.7/>
</svg>
and I use jquery to get the line and find it length with getTotalLength()
var len = $(#line-1).get(0).getTotalLength();
but my browser keeps giving this error warning
Uncaught TypeError: $(...).get(...).getTotalLength is not a function
Can anyone tell me if line element can use getTotalLength()? If not, how can I get the length of the line.
Thanks.
here's my example: https://jsfiddle.net/chitocheng/1h5eckjh/
More From » jquery