Показать сообщение отдельно
  #4 (permalink)  
Старый 30.01.2022, 11:10
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,068

Alexprom,
<!doctype html>
<html>

<head>
    <title></title>
    <meta charset='utf-8' />
    <style>
        .red {
            color: Red;
        }

        .green {
            color: Green;
        }

        .blue {
            color: Blue;
        }
    </style>
</head>

<body>
    <select name="sel" id="sel">
    <option value="">-- Выбрать --</option>
    <option value="red">red</option>
    <option value="green">green</option>
    <option value="blue">blue</option>
</select>
    <div id="toShow" class="variations_button bl">Hello, I am hidden block</div>
    <script>
        var sel = document.getElementById('sel'),
            div = document.getElementById('toShow'),
            current;
        sel.addEventListener('change', function(event) {
            if (current) div.classList.remove(current)
            if (this.value) {
                current = this.value;
                document.getElementById('toShow').classList.add(current);
            }
        })
    </script>
</body>

</html>
Ответить с цитированием