By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,602 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,602 IT Pros & Developers. It's quick & easy.

typeerror document.getelementbyid(...) is null

P: 1
i trying to clear textbox by using this javascript code

document.getElementById("txtUnit").value = ""; or

document.getElementById("txtUnit").innerHTML= ""; both are not working .just getting error like this typeerror document.getelementbyid(...) is null
Jan 20 '14 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,639
that simply means that the element does not (yet) exist at the time you call it.
Jan 20 '14 #2

P: 1
This error TypeError: document.getelementbyid(...) is null would seem to indicate that there is no such element with an ID passed to getElementById() exist. This can happen if the JavaScript code is executed before the page is fully loaded, so its not able to find the element. The solution is that you need to put your JavaScript code after the closure of the HTML element or more generally before < /body > tag.
Feb 25 '19 #3

Post your reply

Sign in to post your reply or Sign up for a free account.