Uncaught TypeError: Cannot set property 'innerHTML' of null
学习Chrome插件时,要在弹出页面中显示当前时间,结果怎样也显示不出来
看了 http://www.cnblogs.com/mfryf/p/3701801.html 这篇文章后感悟颇深
通过调试发现在js中的一段代码没有执行到,报以下错误
Uncaught TypeError: Cannot set property 'innerHTML' of null
然后查询该错误原因,结果是因为js引用放在了页面的头部,在修改 innerHTML 属性时找不到该属性,因为需要修改一个html标签中的内容,因此需要html加载并解析完成之后才能找到对应id的标签,在 head 处引用 js 导致 js 找不到对应 id ,当将 js 引用放在 body 尾部之后就可以正常显示了。
学习了这么久的编程从来没有好好学习过调试程序的方法,一直都在用 console.log() 、syso()、alert(),真得要好好学习一下程序调试的方法了,太受用了
Uncaught TypeError: Cannot set property 'innerHTML' of null的更多相关文章
- JavaScript中"Uncaught TypeError: Cannot set property 'innerHTML' of null"错误
写了一个函数,在调用时出错:"Uncaught TypeError: Cannot set property 'innerHTML' of null" 代码如下: <!DOC ...
- day01-JavaScript中"Uncaught TypeError: Cannot set property 'innerHTML' of null"错误
转行学开发,代码100天.初写了最简的一段Js代码,即通过document中的innerHTML方法修改一个<p>标签的内容,报以下错误. -"Uncaught TypeErro ...
- (转)Uncaught TypeError: Cannot set property 'innerHTML' of null
(转)http://www.cnblogs.com/Ricky-Huang/p/5536253.html 在使用Ueditor的时候,会爆出这样的错误: 浏览器控制台就报错了 Cannot set p ...
- Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
在开发Ext 项目中如果遇到 Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null 这个错误,检查下renderT ...
- Three.js three.js Uncaught TypeError: Cannot read property 'getExtension' of null
在调试Three.js执行加载幕布的时候,突然爆出这个错误three.js Uncaught TypeError: Cannot read property 'getExtension' of nul ...
- JavaScript Uncaught TypeError: Cannot read property 'value' of null
用 JavaScript 操作 DOM 时出现如下错误: Uncaught TypeError: Cannot set property 'value' of null Uncaught TypeEr ...
- 前台报错:Uncaught TypeError: Cannot read property '0' of null
错误现象: var div1=mycss[0].style.backgroundColor; //这一行提示360和chrome提示:Uncaught TypeError: Cannot read ...
- 解决sweetalert 无故报错 elem.className.replace Uncaught TypeError: Cannot read property 'className' of null
今天碰到这么一个问题,在使用sweetalert的时候时有时无会报错 elem.className.replace Uncaught TypeError: Cannot read property ' ...
- vue报错 Uncaught TypeError: Cannot read property ‘children ’ of null
Uncaught TypeError: Cannot read property ‘children ’ of null ratings未渲染完毕,就跳走goods了,取消默认跳转,即可
随机推荐
- cypress的EZ-USB对于USB的介绍
Host is MasterThis is a fundamental USB concept. There is exactly onemaster in a USB system: the hos ...
- 转:CentOS6.3配置yum源
全新以最小化包安装了64位的CentOS6.3系统,作为本地的Web服务器使用,现记录全过程第二步,配置网易163的yum源 1. 下载repo文件 下载地址:http://mirrors.16 ...
- 用UNetbootin来安装USB LINUX,好像比ULTRA ISO省事
UNetbootin can create a bootable Live USB drive, or it can make a "frugal install" on your ...
- [Android] 混音线程MixerThread
MixerThread是Android音频输出的核心部分,所有Android的音频都需要经过MixerThread进行混音后再输出到音频设备. MixerThread的继承关系如下: MixerThr ...
- POJ 1502 MPI Maelstrom( Spfa, Floyd, Dijkstra)
题目大意: 给你 1到n , n个计算机进行数据传输, 问从1为起点传输到所有点的最短时间是多少, 其实就是算 1 到所有点的时间中最长的那个点. 然后是数据 给你一个n 代表有n个点, 然后给你一 ...
- 《Ruby语言入门教程v1.0》学习笔记-02
9.18 第四章 一切都是对象 这个章节的例子都举得很浅显易懂,而且作者的语言= =噗,委实生动有趣啊是~~ 4.1 两种思维方式 初期的编程思想是:以“如何做”为指导来编写代码.这时期的编程语言叫 ...
- Java连接MySQL中文乱码处理【转载】
本文转载地址:http://developer.51cto.com/art/200906/130425.htm 感谢相关作者! MySQL默认编码是latin1 mysql> show vari ...
- banana pro 板子
http://www.lemaker.org/cn/article-23-1.html
- windows2012R2虚拟机快速激活的方法
相信Hyper-v管理员都有这样的经历,安装多台虚拟机后,都要一台一台手工激活,如果虚拟机足够多的话,这是一项很繁琐的工作,但从Windows Server 2012 R2开始,就不需要这么做了,微软 ...
- mac上安装redis
1.从http://redis.io 下载redis包,这里选择了redis-3.2.3 2.将下载的 redis-3.2.3.tar.gz 包拷贝到 /user/local 目录 3.执行 sudo ...