Change text inside persistent symbol with Javascript


#1

This seems like it would be so simple… but I can’t figure it out…

Basically, I have a persistent symbol ID “game” with a text field inside with ID “win_heading”

On load I fure a script and write

hypeDocument.getElementById(“game”).win_heading.innerHTML=“my text”;

Is my syntax completely wrong… please can someone help?

Thank you!


#2

not completely.

You cannot chain “getElementById()” and also you don’t need to use the “game” ID as you can just use it on “win_heading”

hypeDocument.getElementById("win_heading").innerHTML = "my text";

If you need/want to chain it up and restrict to the “game” element then you can do something like:

hypeDocument.getElementById("game").querySelector("#win_heading").innerHTML = "my text";

#3

Thank so much! Worked great :wink: