Error in js

Hi everyone I realise this
No description
17 Replies
Pat66
Pat66•9mo ago
No description
Pat66
Pat66•9mo ago
but in the console I get this message:
No description
Pat66
Pat66•9mo ago
my js file
const temps=document.body.main.time.datetime;
let actuel=new Date().toLocalString();
temps.innerHTML=actuel;
const temps=document.body.main.time.datetime;
let actuel=new Date().toLocalString();
temps.innerHTML=actuel;
can I get some idea to solve this problem thanks
Jochem
Jochem•9mo ago
document.body.main doesn't exist. What are you trying to do? from the three pixels at the top of your second screenshot, I think there's a <time> tag there? you probably want to use document.querySelector('time').datetime;
Pat66
Pat66•9mo ago
Pat66
Pat66•9mo ago
you see ???? "The datatime attribute of the HTML time element is displayed in ISO format. querySelector is not yet available. Try using the tree structure of the DOM as in the example below. document.body.main.time.datetime;"
Jochem
Jochem•9mo ago
not sure what to tell you, document.body.main isn't a thing
Jochem
Jochem•9mo ago
No description
Jochem
Jochem•9mo ago
I don't know what that document you linked is, but querySelector has been a thing for years now. Even if that didn't exist, document.getElementsByTagName('time')[0] would work
Pat66
Pat66•9mo ago
it an exercise i m just going to remove it thanks for your answer
Jochem
Jochem•9mo ago
no worries
Pat66
Pat66•9mo ago
he new code:
const temps=document.querySelector('time').datetime;
let actuel=new Date() .toLocalString();
temps.innerHTML=actuel;
const temps=document.querySelector('time').datetime;
let actuel=new Date() .toLocalString();
temps.innerHTML=actuel;
now I get this error:
Pat66
Pat66•9mo ago
No description
Jochem
Jochem•9mo ago
I think it's toLocaleString
Pat66
Pat66•9mo ago
thanks I m so stupid sometimes
Want results from more Discord servers?
Add your server