- 1
Не работает document.getElementById
При вызове из внешнего файла не работает document.getElementById(id) style.backgroundColor="red";
5 ответов
+ 6
Let the HTML load first, so that you can work on it. Reference:
https://www.sololearn.com/learn/JavaScript/2758/
window.onload = function() {
...your code
}
As far as your objective is concerned, you might wanna alter the CSS for the change in its background color:
window.onload = function() {
document.getElementById("next").style.background="blue";
}
The innerHTML property would paste a text (blue) on your rectangle instead.
0
thanks
0
if I place the code in html it's working
0
but if I place this code in external file it's not working