Solution to "null is null or not an object" in JS

Source: Internet
Author: User

1. 'null' is null or not an object:

<Script type = "text/javascript"> Add the defer = true attribute to it,

That is: <script type = "text/javascript" defer = true>

Defer is used to execute the script after the file is loaded, so that the object cannot be found.

2. document. getElementById is null

Cause: var titab = document. getElementById ("titletab"); no object retrieved
Solution:
1. Add alert (titab) under the error statement to check whether a message box is displayed.
2. If no tab is displayed, check whether the <table> tag of "id = titletab" exists in the HTML code. (Be careful. A letter cannot be wrong)
3. if a tag exists, consider the location of the <script> code segment, remember to include a code similar to getElement. The <script> code segment must appear after the HTML Element. That is to say, you should put the <script> code segment after the

The above two methods can solve the problem .....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.