Last active
October 17, 2023 12:47
-
-
Save baslie/1ac47ea08d31835a8c24ccdce335256d to your computer and use it in GitHub Desktop.
Year in footer (Tilda)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Меняем год в копирайте --> | |
<!-- с помощью тега <strong> --> | |
<script> | |
window.onload = function() { | |
let startYear = '2014'; | |
let className = 'uc-copyright'; | |
let currentYear = new Date().getFullYear(); // Получаем текущий год | |
// Находим элемент <strong> внутри заданного класса | |
let copyrightElement = document.querySelector('.' + className + ' strong'); | |
// Если элемент найден, обновляем его содержимое и стиль | |
if (copyrightElement) { | |
copyrightElement.innerHTML = '© ' + startYear + '-' + currentYear; | |
copyrightElement.style.fontWeight = '300'; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment