Загрузка данных


<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <title>Задание 17</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 50px;
        }
        .interactive-text {
            font-size: 24px;
            font-weight: bold;
            cursor: pointer;
            display: inline-block;
            transition: color 0.1s ease; /* Плавная смена цвета */
        }
    </style>
</head>
<body>

    <p class="interactive-text" id="target-text">
        Наведи на меня мышь, чтобы изменить цвет!
    </p>

    <script>
        const textNode = document.getElementById('target-text');

        // Событие: курсор наведен на текст
        textNode.addEventListener('mouseenter', function() {
            // Генерируем случайный шестнадцатеричный цвет (HEX)
            const randomColor = '#' + Math.floor(Math.random() * 16777215).toString(16);
            this.style.color = randomColor;
        });

        // Событие: курсор убран с текста
        textNode.addEventListener('mouseleave', function() {
            this.style.color = ''; // Возвращает исходный цвет из CSS (черный)
        });
    </script>

</body>
</html>