Jump to content

document.getElementById(id) getting null value!1


Raj_100

Recommended Posts

Maybe your javascript code is running before your document html has loaded.

 

Try wrapping your javascript initial code into an onload event:

 

 

window.addEventListener('load', function() {    var tl = document.getElementById('id');    alert(tl);});
Link to comment
Share on other sites

Is id supposed to be a string or a variable name? You didn't show any code defining any "var id", so I'm assuming that you forgot quotes in your code

Edited by Hadien
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...