Year As Heading On A Webpage - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Year As Heading On A Webpage (615 Views)
| Year As Heading On A Webpage by baggy4luv(op): 12:08pm On Oct 12, 2022 |
I want to use current year as heading as my h1.like 2022 verification exercise....then i want the year should be incremnting. |
| Re: Year As Heading On A Webpage by LTCtech: 12:14pm On Oct 12, 2022 |
baggy4luv:What programming language? JS or PHP? |
| Re: Year As Heading On A Webpage by baggy4luv(op): 12:15pm On Oct 12, 2022 |
LTCtech:Am a newbie either one |
| Re: Year As Heading On A Webpage by Nobody: 3:33pm On Oct 12, 2022 |
baggy4luv:To get the current year in JavaScript, call the new Date() constructor to get a date object and call the getFullYear() method on the result, e.g. new Date(). getFullYear() . The getFullYear method will return a number corresponding to the current year. culled somewhere online |
| Re: Year As Heading On A Webpage by LTCtech: 3:58pm On Oct 12, 2022 |
baggy4luv:Js var today = new Date();Cheers! |
| Re: Year As Heading On A Webpage by baggy4luv(op): 4:55pm On Oct 12, 2022 |
LTCtech:Can it be used as the heading on a webpage |
| Re: Year As Heading On A Webpage by LTCtech: 8:15am On Oct 13, 2022 |
baggy4luv:Yes. Just do var today = new Date();or you could get the h1 tag by id and do innerHTML |
| Re: Year As Heading On A Webpage by truthCoder: 11:56am On Oct 14, 2022 |
| Re: Year As Heading On A Webpage by Zabiboy: 8:09pm On Oct 14, 2022 |
<h1 class="year" > </h1> <s.cript> var year = document.querySelector(".year") year.innerText = new Date().getFullYear() </s.cript> |
| Re: Year As Heading On A Webpage by remi1444: 8:37pm On Oct 15, 2022 |
Zabiboy:use let. ES6 has laid var to rest. |
How To Style A Webpage • How to Create A Webpage Using Html And Host It Using W3space • I Need A Webpage And An App. • 2 • 3 • 4
Tech Companies In Akure, Ondo State, Nigeria • Plz Where Can I Get Hysys 7.3 Or Higher. • Fellow Programmers I Need Your Help Please
