JavaScript JavaScript and the DOM Making Changes to the DOM Getting and Setting Text with textContent and innerHTML

Yosif Qassim
Yosif Qassim
6,367 Points

it didnt work

const input = document.querySelector('input');

const p = document.querySelector('p.d');

const button = document.querySelector('button');

button.addEventListener( 'click' , () => { p.textContent = input.value + " :"; }) \///////

it didnt work

Robert Schaap
Robert Schaap
19,832 Points

Hi Yosif, would be great if you could post the HTML part as well so people can see what you're trying to manipulate.

1 Answer

Dean Paterson
Dean Paterson
12,984 Points

; missing

button.addEventListener( 'click' , () => { p.textContent = input.value + " :"; });