How to change a DOM node value
New Courses Coming Soon
Join the waiting lists
Given a DOM element, how do you change its value?
Change the value of the innerText
property:
element.innerText = 'x'
To lookup the element, combine it with the Selectors API:
document.querySelector('#today .total')
→ Read my DOM Tutorial on
The Valley of Code
→ Read my
Browser Events Tutorial
on The Valley of Code
→ Read my
Browser APIs Tutorials
on The Valley of Code
Here is how can I help you:
- COURSES where I teach everything I know
- CODING BOOTCAMP cohort course - next edition in 2025
- BOOKS 16 coding ebooks you can download for free on JS Python C PHP and lots more
- Follow me on X