0

Why am I getting "document.getelementbyId is null" ??? Any help is appreciate. thx. ... (and it says I need to type more text before I can submit... )

// 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();
NoobSter
  • 1,070
  • 1
  • 13
  • 36

1 Answers1

2

Remove [0] from your document.getElementById('dateDisplay')[0];

document.getElementById does not return an array, so there is no point in having an index pointer.

kidA
  • 1,349
  • 1
  • 9
  • 19