错误提示:Uncaught TypeError: Cannot read property 'style' of undefined at HTMLDocument.myfun1请教各位!
错误提示:Uncaught TypeError: Cannot read property 'style' of undefined at HTMLDocument.myfun1请教各位!
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- CSDN专家-天际的海浪 2021-08-30 22:53关注
错误提示:Uncaught TypeError: Cannot read property 'style' of undefined
这个错误是指 调用这个style属性的对象是 undefined
比如你的代码是 obj.style
就是指obj变量的值是 undefined,undefined不是对象,没法调用style属性
这种情况一般是因为用document.getElementById("id")没有获取到dom对象
或者也常见于数组下标越界的情况。
如你的代码是for (var i = 0; i <= 6; i++) arr[i].style
比如arr数组下标只有0到5元素存放了有style属性的对象。
当i=6时下标越界, arr[i]的值就是 undefinedarr[i].style 也就成了 undefined.style
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统
- ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
- ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本