Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get text value from Element

ANSWERED

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>

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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. 🙂

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
5 REPLIES 5

I haven't tried it, but it might be something like

let marqueeEl = document.getElementById('marquee');
let text = marqueeEl.text;
Peter McLennan
Gondwana Software
Best Answer
0 Votes

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

 

Best Answer
0 Votes

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. 🙂

Peter McLennan
Gondwana Software
Best Answer

I laugh at no one who can provide me with a working piece of code! Thank you!!

Best Answer

🙂

Peter McLennan
Gondwana Software
Best Answer
0 Votes