+ 2
getElement js not working
4 ответов
+ 1
window.addEventListener ("DOMContentLoaded", init);
function init () {
let first = document.querySelector("#one");
console.log(first.textContent);
}
+ 1
onload=()=>{
let first = document.querySelector("#one");
console.log(first.textContent);
}
The use of onload is necessary to wait for the html-document to be completely loaded, since in SoloLearn JavaScript is loaded first and does not see the tag with id="one".