🏠 Go back to the homepage

How to change a DOM node value

Given a DOM element, how do you change its value?

Published Oct 23 2018

Change the value of the innerText property:

element.innerText = 'x'

To lookup the element, combine it with the Selectors API:

document.querySelector('#today .total')

Download my free JavaScript Beginner's Handbook!

Logo



Free ebooks

JavaScript Python React HTML CSS Node.js Linux C Express.js Next.js How to Start a Blog


Knitting tutorials

© Flavio Copes

PREMIUM COURSES 👀

JavaScript Masterclass (next cohort in November) Web Development Bootcamp (next cohort 2023)

Free ebooks 👇🏼

JavaScript Python React HTML CSS Node.js Linux C Next.js How to Start a Blog

Browse by topic

Astro Blogging C Career Computer CLI CSS Database DevTools Docker Electronics Express.js Git Golang GraphQL HTML JavaScript Flavio's Lab Mac / iOS Misc Networking Next.js Node.js Phaser Python React Redis Services Svelte Swift Tools Vue.js DOM

You might also like

  • How to use insertAdjacentHTML
  • How to make an hr invisible
  • How to remove all children from a DOM element
  • How to loop over DOM elements from querySelectorAll
  • The Navigator Object
  • How to work with scrolling on Web Pages
  • What are Data URLs
  • The History API
  • Learn how HTTP Cookies work
  • ArrayBufferView

© Flavio Copes