-1

I tried practising Dom in js with a video I watched.

Html

input id="hi" type="submit"

Javascript

var hi = document.getElementById('hi');

hi.text content ='hello';

But the text content didn't change. It instead gave an error: property of null. What is my mistake and what does that mean

David
  • 1

1 Answers1

1

You cannot have a space in any variable/method names. JavaScript will think you're defining two separate things.

Instead of: hi.text content = 'hello';

Try: hi.textContent = 'hello';

Josh Hunt
  • 12,949
  • 26
  • 73
  • 96
petegoast
  • 55
  • 8