提示错误Cannot read properties of null (reading ‘value‘)
出现这个错误,是因为把id获取错误,改过来便可。
<input type="text" id="txt">var txt = document.getElementById("text");// txt写成text<body><p><input type="text" id="txt"><button id="btnAdd">添加</button></p><ul><li><span>列表1</span><button>删除</button></li><li><span>列表2</span><button>删除</button></li><li><span>列表3</span><button>删除</button></li></ul><script>var btnAdd = document.getElementById("btnAdd");//出现错误的地方var txt = document.getElementById("txt");var ul = document.getElementsByTagName("ul")[0];btnAdd.onclick = function () {var value = txt.value;var li = document.createElement("li");li.innerHTML = ` <span>列表${value}</span><button>删除</button>`ul.appendChild(li);txt.value = "";}</script>
提示错误Cannot read properties of null (reading ‘value‘)相关推荐
- [Vue warn]: Error in mount hook: “TypeError: Cannot read properties of null (reading ‘getAttribute‘)
在vue项目中,使用echarts报一下的错误: [Vue warn]: Error in mount hook: "TypeError: Cannot read properties of ...
- 15 flvjs 播放 ws 服务代理的不存在的 rtsp 连接, Cannot read properties of null (reading ‘flushStashedSamples‘)
前言 这是基于 flvjs 播放 rtsp视频服务 基于node+ffmpeg 转换为 flv 视频服务 的时候, 衍生出来的一个问题 在生产环境上面, 很大一部分 rtsp 服务是正常的可以播放的, ...
- TypeError: Cannot read properties of null (reading ‘indexOf‘)
问题描述: TypeError: Cannot read properties of null (reading 'indexOf') 意思是:TypeError:无法读取null的属性(读取'ind ...
- 高德地图点聚合插件AMap.MarkerClusterer报错Uncaught TypeError: Cannot read properties of null (reading ‘Md‘)
报错信息:Uncaught TypeError: Cannot read properties of null (reading 'Md') mapscallback=___onAPILoaded&a ...
- TypeError: Cannot read properties of null (reading ‘insertBefore‘)
TypeError: Cannot read properties of null (reading 'insertBefore') vite build vue3之后线上报错! 项目版本 vue3 ...
- vue TypeError: Cannot read properties of null (reading 'insertBefore')
这个错误通常是由于在组件中使用了 insertBefore 方法时,试图插入到一个不存在的父节点导致的.您可以使用 v-if 指令或在 JavaScript 代码中进行 null 值检查来避免这种情况 ...
- 在git bash中输入git init 提示错误信息: fatal: open /dev/null or dup failed: No such file or directory的解决办法
将C:\Windows\System32\drivers目录下的null.sys更换为网盘里下载的null.sys文件,重启电脑完美解决! 链接: https://pan.baidu.com/s/1Z ...
- 引入echarts的js文件报错——Cannot read properties of null (reading ‘getAttribute‘)
今天在引入echarts.min.js的时候总是报错: 报错如下: 该问题为:无法读取空的属性"获取属性" 根据分析,错误原因有两个: 1.初始化echarts对象不存在 2.js ...
- npm 报错 ERR Cannot read properties of null reading ‘package npm ERR A complete log of this run can
通过npm install 安装依赖报如下错误. 解决办法:尝试通过cnpm install 或yarn install 即可解决.
最新文章
- 参加软件测试培训需要注意哪些
- 学python工资高吗-我程序员年薪 80 万被亲戚鄙视不如在二本教书的博士生?
- Latex 数学符号表
- boid模型的Matlab程序,动物集群运动行为模型系列之五-—本科毕业设计.doc
- 输入一个正整数n,计算s=1-1/3+1/5-1/7…前n项之和
- dockerHub国内镜像设置
- qlineedit只能输入数字_Qt编写自定义控件51-可输入仪表盘
- python3中exec_Python3
- JAVA计算一年的第几天问题
- 第七章 二叉搜索树 (d2)AVL树:插入
- asp.net 母版页使用方法
- 【转】 sqlserver 异地备份
- Linked List Cycle给定一个链表,判断其中是否有环。
- 解决电脑屏幕显示器亮度无法调节可能与远程工具向日葵有关
- 如何选择物业管理软件,五大误区需要避免
- 自媒体内容采集工具,采集多个自媒体平台内容
- 回归、自回归、循环神经网络(RNN)、LSTM
- FL Studio20.9DAW宿主电子音乐制作软件
- 程序输出我是java小公主,我的同学英文
- 通过MapReduce统计PV和UV