buster808 Posted May 29, 2021 Share Posted May 29, 2021 Hi, I'm using this code from the remarkable https://www.creativecodingclub.com/ I want to use the counter with a svg tspan. <text id="portValueNum" class="cls-29" transform="translate(298.56257 235.84268)"> <tspan id="manage" xml:space="preserve">1000</tspan> </text> Is this even possible. I tried changing, let elements = document.querySelectorAll("tspan") but no cigar. Thanks See the Pen NWRqmOv by snorkltv (@snorkltv) on CodePen Link to comment Share on other sites More sharing options...
Solution Cassie Posted May 29, 2021 Solution Share Posted May 29, 2021 It's always good to pop in a demo so we know what you've tried. I assume you're trying to use HTML DOM methods on an SVG element though. You're probably looking for tspan.textContent instead of tspan.innerText See the Pen bGqYGrm?editors=1111 by GreenSock (@GreenSock) on CodePen 1 1 Link to comment Share on other sites More sharing options...
PointC Posted May 29, 2021 Share Posted May 29, 2021 Yep - you want .textContent. https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent See the Pen OJpOLqx by PointC (@PointC) on CodePen 2 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now