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

Change button text in code

ANSWERED

How can I change the text of a button in code?  I have the button displaying, but I need ot change the text in code.  I have a REST call getting data, and part of the data gets the text to use on the button, I just have not found a way to reference the button's text.

 

  <use id="mybutton" href="#square-button-icon" y="5" fill="coral">
    <set href="#text"  attributeName="text-buffer" to="Steps" />
  </use>
Best Answer
1 BEST ANSWER

Accepted Solutions

Try the following:

 

 

var Button1 = document.getElementById("mybutton");
//Set Button Text
Button1.text = "New Text";

Let me know if you have any issues. 

 

View best answer in original post

Best Answer
3 REPLIES 3
Best Answer
0 Votes

I have a reference to the button element, but you can't set innerText on the element.

Best Answer
0 Votes

Try the following:

 

 

var Button1 = document.getElementById("mybutton");
//Set Button Text
Button1.text = "New Text";

Let me know if you have any issues. 

 

Best Answer