Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change text in HTML element from p5.js?

Tags:

p5.js

I'm just trying out p5.js. I'd like to change some HTML text (not on the p5 canvas) from p5. Something like:

score_display = createElement("text", "Score: 0");
...
score_display.nodeValue = "Score: " + score; // doesn't work

How do I do this? Thanks.

like image 722
David Matuszek Avatar asked Sep 11 '25 11:09

David Matuszek


1 Answers

There is an .html() property in p5.js to change innerHTML of an element.

Admittedly difficult to find in their reference documentation. Perhaps they are deprecating? https://p5js.org/reference/#/p5.Element/html

like image 50
artificialarea Avatar answered Sep 13 '25 15:09

artificialarea