document.getElementById为null?...我的代码有什么问题..?

新手

为什么我得到“ document.getelementbyId为空”的信息?任何帮助,感激不尽。谢谢。...(它说我需要输入更多文本才能提交...)

// get current date - in format
  function thisDate(){
    var today = new Date(),
     dd = today.getDate(),
     mm = today.getMonth() + 1, 
     yyyy = today.getFullYear();

    if (dd < 10) {
      dd = '0' + dd
    }

    if (mm < 10) {
      mm = '0' + mm
    }

    today = mm + ',' + dd + ',' + yyyy;

    dateDisplay =  document.getElementById('dateDisplay')[0];
    dateDisplay.innerHTML = today.toString();
    console.log(today);
  }
  thisDate();
小子

[0]从您的中删除document.getElementById('dateDisplay')[0];

document.getElementById 不返回数组,因此拥有索引指针毫无意义。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我找不到错误?TypeError:document.getElementById(...)为null

所有 document.getElementById('') 返回 null

我的useEffect代码有什么问题,为什么状态变量为空?

或者被指示为无效的语法,我的代码有什么问题?

下拉菜单设置为System.Data.DataRow,我的代码有什么问题?

Adobe Brackets实时预览为空白。我的代码有什么问题?

我的代码“beautifulsoup”有什么问题?CSV 始终为空

getElementById有什么问题

TypeError:document.getElementById(...)为null不会停止出现

如何将 document.getElementById(...) is null 设置为 true

在异常TypeError上暂停:document.getElementById(...)为null

TypeError:document.getElementById(...)在javascript中为null

为什么document.getElementById在这里返回null?

我的python代码有什么问题,我正在尝试为文件添加实现多个文件搜索条件

在调用$(document).ready(function(){...})之后,为什么document.getElementById调用为null?

document.getElementById() 为空

document.getElementById()返回null

document.getElementById返回null

for 循环的 document.getElementById 问题

JavaScript document.getElementById问题

当存在具有该 ID 的元素时,为什么 document.getElementById() 返回 null?

为什么我的JavaScript中的document.body为null?

我在我的 python 程序中为下面描述的问题使用的逻辑有什么问题?

Vuejs + Google Maps> document.getElementById,this.refs为div返回null

document.getElementById(“ elementId”)。innerHTML =()的倍数,导致第二个返回为null

需要检查用户输入是否为数字。代码未按预期工作。有人可以告诉我出了什么问题吗?

为什么document.write和console.log为getElementById提供不同的输出?

为什么Flow仍然抱怨document.getElementById为空值

如果具有给定ID的元素存在,则document.getelementbyid('ID')方法返回null