Change button name programmatically

Hi.
Is it possible to change the name of a button programmatically?

Something like:

button = createButton("one");
button.position(0, 0);
button.mousePressed(changeName);

function changeName() {
  button.value = "two";  // ??
}
1 Like

p5js.org/reference/#/p5.Element/html

2 Likes

Thanks, that works!

let toggle = true;

function setup() {
  createCanvas(100, 100);
  button = createButton("one");
  button.position(0, 0);
  button.mousePressed(fnc);
}

function draw() {
  background(220);
}

function fnc() {
 if (toggle) button.html('two');
 else button.html('one');
 toggle =! toggle;
}