I am having trouble using select() to get a span element in the DOM. It looks like it is a bug or I’m doing something wrong. Here is the link: https://editor.p5js.org/im-griff/sketches/D7tf9TAC0
Or below here is the code:
In index.html
<p>You have <span class=".points">0</span> Points.</p>
In sketch.js
var span;
var points = 0;
function setup() {
createCanvas(200, 200);
// Selecting the <span class=".points"></span> element in index.html
span = select('.points');
// Replace html with the variable points, which is 0
span.html(points);
}
function draw() {
// If the code succeeds, the background will be red
background(255,0,0);
}
This results with an error “span is null (sketch: line 11)”
This also yields the same result if I take the span out of the
I believe this is a bug unless anyone has any solutions,
Thank you