0

why it's showing cannot set textContent = null

my code is document.getElementById('score-0').textContent = 0; document.getElementById('score-1').textContent = 0; document.getElementById('current-0').textContent = 0; document.getElementById('current-1').textContent = 0; document.getElementById('name-0').textContent = 'Player 1' document.getElementById('name-1').textContent = 'Player 2' document.querySelector('.player-0-panel').classList.remove ('winner'); document.querySelector('.player-1-panel').classList.remove ('winner'); }

18th Jan 2018, 3:31 PM
ANSHIF BABU AS
2 ответов
+ 5
Two reasons getElementById fails are: 1. DOM isn't ready, use window.onload() or jQuery 'ready' pattern 2. id's aren't set properly A CodePlayground link would help people be more specific for your case.
18th Jan 2018, 4:05 PM
Kirk Schafer
Kirk Schafer - avatar
0
so what's the solution to do it without a framework.
18th Jan 2018, 5:15 PM
ANSHIF BABU AS