Uncaught TypeError: Cannot read property 'setSelectionRange' of null

解决参考:https://bbs.****.net/topics/390628759

步枯:“很明显,取id没取到。。。仔细检查一下id定义是否正确”

支付宝加好友偷能量挖:var obj = document.getElementById("c_message_content") 对象不存在咯

 

我的问题:

在学习js的时候,看todolist源码http://www.todolist.cn/,然后copy下来后运行会有报错:

`Uncaught TypeError: Cannot read property 'setSelectionRange' of null`

然后,参考博客后查看源码,是函数edit中多了个空格,getElementById获取不到正确的id,去掉后就好了。

 

Uncaught TypeError: Cannot read property 'setSelectionRange' of null