I'm trying to learn JavaScript and experiment a bit, but I'm stuck on how to extract the value from between HTML tags. Here's what I have: I want to check if the text inside a `td` element (with ID 'statusBox') is 'Ready'. If it is, I want to change the background color to green; otherwise, I want it to turn red and show the current value. However, my current implementation isn't working as intended. Here's the code I'm using:
```html
| Ready |
if(document.getElementById('statusBox').nodeValue == 'Ready'){
document.getElementById('statusBox').style.backgroundColor = 'green'
} else {
document.getElementById('statusBox').style.backgroundColor = 'red'
alert(document.getElementById('statusBox').nodeValue)
}
```
3 Answers
Honestly, I've worked a lot with the DOM and I've rarely used `nodeValue`. Make sure to have a solid learning path. The MDN docs are a great resource for picking up structured knowledge in web development!
MDN is life!
You should try using `.innerHTML` to get the content from the `td` element. It’ll work for what you’re trying to do!
That did it. Thanks a lot!
You can also use `.innerText` or `.textContent` for this. Both should get you the text you need!

Much appreciated! I was just googling and experimenting in my IDE. That's how I ended up here lol.