# Can't select \<span\> element in DOM bug

**URL:** <https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980>\
**Category:** Beginners\
**Created:** [June 30, 2021, 4:31pm UTC](https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980 "2021-06-30T16:31:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![griff](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@griff](https://discourse.processing.org/u/griff)\
**Post date:** [June 30, 2021, 4:31pm UTC](https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980/1 "2021-06-30T16:31:45Z")

</div>

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](https://editor.p5js.org/im-griff/sketches/D7tf9TAC0)

Or below here is the code:

In index.html

```auto
<p>You have <span class=".points">0</span> Points.</p>

```

In sketch.js

```auto
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 😀

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 30, 2021, 4:39pm UTC](https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980/2 "2021-06-30T16:39:56Z")

</div>

> [@griff](#):
>
> `<p>You have <span class=".points">0</span> Points.</p>`

`<p>You have <span class="points">0</span> Points.</p>`

---

<div class="post-metadata">

**Author:** ![griff](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@griff](https://discourse.processing.org/u/griff)\
**Post date:** [June 30, 2021, 4:41pm UTC](https://discourse.processing.org/t/cant-select-span-element-in-dom-bug/30980/3 "2021-06-30T16:41:34Z")

</div>

Ah. Classic… it’s always the little things.  
Thank you for your eye
