出现这个错误,是因为把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‘)相关推荐

  1. [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 ...

  2. 15 flvjs 播放 ws 服务代理的不存在的 rtsp 连接, Cannot read properties of null (reading ‘flushStashedSamples‘)

    前言 这是基于 flvjs 播放 rtsp视频服务 基于node+ffmpeg 转换为 flv 视频服务 的时候, 衍生出来的一个问题 在生产环境上面, 很大一部分 rtsp 服务是正常的可以播放的, ...

  3. TypeError: Cannot read properties of null (reading ‘indexOf‘)

    问题描述: TypeError: Cannot read properties of null (reading 'indexOf') 意思是:TypeError:无法读取null的属性(读取'ind ...

  4. 高德地图点聚合插件AMap.MarkerClusterer报错Uncaught TypeError: Cannot read properties of null (reading ‘Md‘)

    报错信息:Uncaught TypeError: Cannot read properties of null (reading 'Md') mapscallback=___onAPILoaded&a ...

  5. TypeError: Cannot read properties of null (reading ‘insertBefore‘)

    TypeError: Cannot read properties of null (reading 'insertBefore') vite build vue3之后线上报错! 项目版本 vue3 ...

  6. vue TypeError: Cannot read properties of null (reading 'insertBefore')

    这个错误通常是由于在组件中使用了 insertBefore 方法时,试图插入到一个不存在的父节点导致的.您可以使用 v-if 指令或在 JavaScript 代码中进行 null 值检查来避免这种情况 ...

  7. 在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 ...

  8. 引入echarts的js文件报错——Cannot read properties of null (reading ‘getAttribute‘)

    今天在引入echarts.min.js的时候总是报错: 报错如下: 该问题为:无法读取空的属性"获取属性" 根据分析,错误原因有两个: 1.初始化echarts对象不存在 2.js ...

  9. npm 报错 ERR Cannot read properties of null reading ‘package npm ERR A complete log of this run can

    通过npm install 安装依赖报如下错误. 解决办法:尝试通过cnpm install 或yarn install 即可解决.

最新文章

  1. 参加软件测试培训需要注意哪些
  2. 学python工资高吗-我程序员年薪 80 万被亲戚鄙视不如在二本教书的博士生?
  3. Latex 数学符号表
  4. boid模型的Matlab程序,动物集群运动行为模型系列之五-—本科毕业设计.doc
  5. 输入一个正整数n,计算s=1-1/3+1/5-1/7…前n项之和
  6. dockerHub国内镜像设置
  7. qlineedit只能输入数字_Qt编写自定义控件51-可输入仪表盘
  8. python3中exec_Python3
  9. JAVA计算一年的第几天问题
  10. 第七章 二叉搜索树 (d2)AVL树:插入
  11. asp.net 母版页使用方法
  12. 【转】 sqlserver 异地备份
  13. Linked List Cycle给定一个链表,判断其中是否有环。
  14. 解决电脑屏幕显示器亮度无法调节可能与远程工具向日葵有关
  15. 如何选择物业管理软件,五大误区需要避免
  16. 自媒体内容采集工具,采集多个自媒体平台内容
  17. 回归、自回归、循环神经网络(RNN)、LSTM
  18. FL Studio20.9DAW宿主电子音乐制作软件
  19. 程序输出我是java小公主,我的同学英文
  20. 通过MapReduce统计PV和UV

热门文章

  1. AC框架与DQN在《只狼》以及《黑暗之魂》中的应用
  2. 【GitHub】GitHub上值得收藏的100个精选前端项目!
  3. 超声波传感器--Arduino
  4. 在vue3setup语法糖中获取DOM元素
  5. 樱花的季节,教大家用canvas画出飞舞的樱花树
  6. MySQL--新手必备SQL基础知识、事务ACID及隔离级别
  7. 通证大局观(二):通证权益解析
  8. 软件设计师-数据结构知识
  9. vmware虚拟机检测不到vspd虚拟串口问题
  10. linux-文件系统管理10-关于存储介质的那些事儿