I'm starting in javascript. I have two questions in one. I would like to show the date in a specific 'id', And use multiple 'id' in a same function. (data will appear several times in the site)
As: id="date1" id="date2" id="date3"
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
document.write(today);
I know I have to use this line but I do not know how to apply it:
document.getElementById("date").innerHTML
textContent?innerTextis nonstandard.innerTextbecause of its.... oddities. Mostly around linebreaks.