Skip to content
Advertisement

How to bind every day of a week dynamically to every h1 in HTML

Hi any idea how to bind every day of a week to every h1 in a way the first h1 shows today, and the next h1 shows tomorrow and the 7th h1 shows the 7th day from toady ? I did this my max was I can only make all of them show toady.. thanks

JavaScript
JavaScript

Advertisement

Answer

You can retrieve a localized day of the week using Date.prototype.toLocaleDateString and passing in the option { weekday: 'long' }.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement