10th Sep 2023, 7:13 AM
Alex Wairegi
Alex Wairegi - avatar
7 Respostas
+ 7
Alex Wairegi Your code is correct,but the error is you have not written all the tags in the right place. Always remember, Write the script tag inside the body tag. If you don't do this, it will always tell you error. See this modified version.. https://code.sololearn.com/WLd10a2eFvDO/?ref=app
10th Sep 2023, 7:33 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 7
In addition to above you could add and must not waiting long time (ca. 1 minute) to see a change of displayed time: var seconds = now.getSeconds(); var y = hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
10th Sep 2023, 8:00 AM
JaScript
JaScript - avatar
+ 5
Alex Wairegi most welcome, Happy learning :)👍
10th Sep 2023, 7:47 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 3
Hey dude, first off if you need more help please describe ur problem better. So i think you want to display the current time so i did some changes on your code and add comments for you that help you to understand what i did. I wrote a new function to display the time too. Hope that help you. Happy coding ✌️ https://code.sololearn.com/Wb64MHr0g27Z/?ref=app https://sololearn.com/compiler-playground/Wb64MHr0g27Z/?ref=app
10th Sep 2023, 7:43 AM
S3R43o3
S3R43o3 - avatar
+ 2
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <title>Page Title</title> </head> <body> <div id="clock" aria-live="assertive"></div> <div id="circle1"></div> <div id="circle2"></div> <script src="script.js" defer></script> </body> </html> ------------------------------------------------------------------------------------------------- #clock { width: 200px; height: 80px; border: 1px solid rgba(255, 255, 255, 0.1); position: absolute; top: 250px; left: 80px; background-color: rgba(255, 255, 255, 0.04); backdrop-filter: blur(20px); border-radius: 5px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5); z-index: 2; font-size: 24px; display: flex; align-items: center; justify-content: center; color: white; /* Set the text color to white */ } -------------------------------------------------------------------------------------------------- function updateClock() { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var timeString = hours + ":" + (minutes < 10 ? "0" : "") + minutes; var element = document.getElementById("clock"); element.textContent = timeString; } updateClock(); var clockInterval = setInterval(updateClock, 1000); Try with this code !
10th Sep 2023, 7:45 AM
Fabian Roy
Fabian Roy - avatar
+ 2
Thanks everyone especially Darpan kesharwani🇮🇳
10th Sep 2023, 7:45 AM
Alex Wairegi
Alex Wairegi - avatar
0
Why we are all copy other algrthim like sort and search let's build our own algorithm and data structures guys keep support IAM new to this sololearn keep support
11th Sep 2023, 2:21 PM
Mohammed Irfan
Mohammed Irfan - avatar