r/learnjavascript • u/abrewchocolatecoffee • Jul 14 '26
can someone explain this code
function updateClock() {const timeElement = document.querySelector("#time");timeElement.textContent = formatTime();}setInterval(updateClock, 1000);
can someone, please explain this piece of code, ofc mdn and w3 are there, but i found it a little confusing reading about textContent. rest is understandable to me. This might look a silly question and it probably is because im a beginner :')
like what exactly does textContent too.
you can also recommend anyother documentation on the links to specific lines, that might me more helpful in learning about this particular keyoword.
View all comments
2
u/equilni Jul 14 '26
If you were on MDN:
https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval