Workshop › Text detective › Step 3 of 13
Right now the count is made once, when the page opens. We put it in a function and run it again every time the text changes.
```js
function update() {
result.textContent = 'Characters: ' + box.value.length
}
box.addEventListener('input', update)
update()
```update does the report; defining it does not run it.addEventListener('input', update) runs update each time the box's text changes.update() makes the first report when the page opens.Wrap the last line in function update() { ... }, then add the listener and the first call.
Skills: Functions, Keyboard and mouse input
← Count the characters Split into words →