0
I am trying to select HTML elements using document.getElementById method but it keep showing null reference. how to fix it?
4 Respostas
+ 11
Try to wrap ur js code in :
window.onload =function( ) {
/ / Write ur code here..
}
Also make sure that u have an html element with that id.
If ur code still doesn't get fixed, post it here so that we can help.
+ 9
You can use script tag in both head and body..
But if u are putting it in head, u need that function so that ur javascript will run only after html loads so that u can grab html elements.....
0
Thanks It worked!!!
script tag must in the head tag behind the scenes, right?
0
Thanks!