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

Ruslantech,
<!DOCTYPE html>
<html lang="ru">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>JavaScript</title>
        <style>

        </style>
    </head>
    <body>

            <p>Lorem ipsum dolor sit amet.</p>
            <input type="checkbox" value="text-decoration:line-through;"><span>перечеркнуть</span>
            <input type="checkbox" value="font-weight:bold;"><span>сделать жирным</span>
            <input type="checkbox" value="color:red;"><span>сделать красным</span>
        <script>
            let text = document.querySelector('p')
            let input = document.querySelectorAll('input')
            for(var i = 0; i < input.length; i++){
                input[i].addEventListener('change', func)
            }

            function func(){
                var txt = '';
                for(var i = 0; i < input.length; i++){
                var el = input[i];
                if(el.checked) txt += el.value
                }
                text.style.cssText = txt
            }
        </script>
    </body>
</html>
Ответить с цитированием