Например, так...
<!DOCTYPE html>
<html>
<head>
<title>Алфавит</title>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto:300&display=swap" rel="stylesheet">
</head>
<style>
html {
font: 1em Roboto, sans-serif;
}
input, button {
font: inherit;
}
#fix {
display: flex;
flex-wrap: wrap;
width: 100%;
height: auto;
}
.mix {
border: none;
color: white;
background-color: #1C3CE3;
width: 30px;
height: 30px;
margin: 5px;
text-align: center;
font-size: 24px;
}
</style>
</head>
<body>
<input type="text" id="myInput" placeholder="Введите текст" class="Inp">
<div id="fix"></div>
</body>
<script>
const fix = document.getElementById("fix"), myInput = document.getElementById("myInput");
myInput.addEventListener("input", function(event) {
const target = event.target;
fix.textContent = "";
for(const character of target.value) {
const button = document.createElement("button");
button.className = "mix";
button.textContent = character;
fix.append(button);
}
});
fix.addEventListener("click", function(event) {
const target = event.target.closest(".mix");
if(!target) return;
target.remove();
myInput.value = fix.textContent;
});
</script>
</html>
Используйте вместо <div> — кнопку <button>
|