07-27-2021 09:54
07-27-2021 09:54
Hi, I'm just implementing a scrolling text element in which the text is dynamically set. I have it all working fine now. But for another feature, I need to get that text from the element (see below). Can anyone help me out? Thanks!
PS. I pulled this exact code from here (changing values as I needed): https://dev.fitbit.com/build/guides/user-interface/svg-components/text/#dynamic-textarea
<svg id="forecast" viewport-fill="fb-red" display="none" class="weatherInfo">
<use id="marquee" href="#marquee-text" font-size="20" width="41%"
height="21" fill="white" mode="1" value="50">
<rect width="100%" height="100%" fill="none" opacity="0.2" />
<set href="group/text" attributeName="text-buffer" />
<set href="group/separator" attributeName="width" to="50" />
</use>
</svg>
Answered! Go to the Best Answer.
07-27-2021 14:17
07-27-2021 14:17
Do you promise not to laugh at me?
marqueeEl.getElementById('group/text').text
I suspect that Fitbit implemented a setter for marquee.text, but not a getter.
Of course, if you're writing to .text, you could just keep track of what you're writing. 🙂
07-27-2021 13:33
07-27-2021 13:33
I haven't tried it, but it might be something like
let marqueeEl = document.getElementById('marquee');
let text = marqueeEl.text;
07-27-2021 13:45 - edited 07-27-2021 13:51
07-27-2021 13:45 - edited 07-27-2021 13:51
Sadly, I've tried this already and it just returns nothing.. I'm thinking it has something to do with the HTML tags, but I'm not sure what since I'm setting the text using:
let marqueeEl = document.getElementById('marquee');
marqueeEl.text = "My data string";
And it works as intended, just not able to retrieve the text
07-27-2021 14:17
07-27-2021 14:17
Do you promise not to laugh at me?
marqueeEl.getElementById('group/text').text
I suspect that Fitbit implemented a setter for marquee.text, but not a getter.
Of course, if you're writing to .text, you could just keep track of what you're writing. 🙂
07-27-2021 15:58
07-27-2021 15:58
I laugh at no one who can provide me with a working piece of code! Thank you!!
07-27-2021 16:00
07-27-2021 16:00
🙂