<header>
<h2 class="title">Метод blur()</h2>
<p class="description">Цей приклад демонструє використання методу `blur()` для розфокусування текстового поля.</p>
</header>
<main>
<div class="result">
<input type="text" id="textInput" placeholder="Введіть текст...">
<button id="focusButton">Фокус на текстовому полі</button>
<button id="blurButton">Розфокус на текстовому полі</button>
</div>
</main>
body {
font-size: 16px;
line-height: 1.5;
font-family: Arial, sans-serif;
}
header {
background-color: #f1f1f1;
margin-bottom: 25px;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
header h2.title {
padding-bottom: 15px;
border-bottom: 1px solid #999;
}
header p.description {
font-style: italic;
color: #222;
}
.result {
background-color: #f8f8f8;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
input[type="text"] {
padding: 10px;
margin-right: 10px;
margin-bottom: 6px;
border: 1px solid #ccc;
display: block;
}
button {
padding: 10px 20px;
background-color: #007BFF;
color: #fff;
border: none;
cursor: pointer;
display: block;
margin-bottom: 6px;
}
document.addEventListener('DOMContentLoaded', () => {
const textInput = document.getElementById('textInput');
const focusButton = document.getElementById('focusButton');
const blurButton = document.getElementById('blurButton');
focusButton.addEventListener('click', () => {
textInput.focus();
});
blurButton.addEventListener('click', () => {
textInput.blur();
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.