Error: Uncaught TypeError: Cannot read property 'value' of null

前端 未结 5 1138
忘了有多久
忘了有多久 2021-01-29 15:05

i want to know why this error is occuring \"Uncaught TypeError: Cannot read property \'value\' of null\" and where i am going wrong?

 function create()
                 


        
5条回答
  •  孤城傲影
    2021-01-29 15:16

    I've encountered a similar problem before:

    "Uncaught TypeError: Cannot read property 'value' of null"

    Means that you're probably didn't set an id in order for the function to look for the value, so it can retrieve it.

    Example:

    
    
    function myfunc() { text = document.getElementById('msg').value; }

    This will return the following error you get. Correct approach:

    
    
    function myfunc() { text = document.getElementById('msg').value; }

    Hope that helps!

提交回复
热议问题