typeerror document.getelementbyid(...) is null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sathisha
    New Member
    • Jan 2014
    • 1

    typeerror document.getelementbyid(...) is null

    i trying to clear textbox by using this javascript code

    document.getEle mentById("txtUn it").value = ""; or

    document.getEle mentById("txtUn it").innerHTM L= ""; both are not working .just getting error like this typeerror document.getele mentbyid(...) is null
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that simply means that the element does not (yet) exist at the time you call it.

    Comment

    • jacobhalls
      New Member
      • Feb 2019
      • 1

      #3
      This error TypeError: document.getele mentbyid(...) 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.

      Comment

      Working...