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

Da-bro,
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta name="description" content="">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://fonts.googleapis.com/css?family=Roboto:100&display=swap" rel="stylesheet">
<style>
    #fix {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        height: auto;
    }
    .mix{
        color: White;
        background-color: #1C3CE3FF;
        width: 30px;
        height: 30px;
        margin: 5px;
        text-align: center;
        font-size: 24px;
    }
</style>

<title>Алфавит</title>
</head>
<body>
    <div id="fix"></div>
    <input type="text" id="myInput" placeholder="Введите тект" class="Inp" >



</body>
<script>
        const inp_var = document.getElementById("myInput");
        const enter_text = text => [...text].map(a => {
                const para = document.createElement('div');
                para.className = "mix";
                para.textContent = a;
                return para
            })

        const out = _ => {
            const inp_value = inp_var.value;
            fix.textContent = "";
            fix.append(...enter_text(inp_value))
        }
        inp_var.addEventListener("input", out)
        inp_var.addEventListener("keyup", out)

        fix.addEventListener("click", ({target}) => {
        if(target = target.closest(".mix")) {
            target.remove();
            inp_var.value = fix.textContent;
            out()
        }
        })

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