I am trying to use year multiple times in an HTML page using the below script
$('#year').text(new Date().getFullYear());
It is getting displayed first time but 2nd time it is not working. I am using below code in html
<p>Copyright ©
First Time<span id="year"></span> - Second Time<span id="year"></span>
</p>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Jquery Date issue</title>
</head>
<body>
<p>Copyright ©
First Time<span id="year"></span> - Second Time<span id="year"></span>
</p>
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
// Get the current year for the copyright
$('#year').text(new Date().getFullYear());
</script>
</body>
</html>
The code is here https://jsfiddle.net/vptechworld/z0gmobyw/5/
` should be inside, not outside, the document.
– Pointy Feb 03 '19 at 13:54