<header>
<h2 class="title">element.style.counterIncrement</h2>
<p class="description">Метод встановлює збільшення лічильника CSS для елементів</p>
</header>
<main>
<div class="controls">
<label for="counterIncrement">Значення збільшення лічильника (наприклад, 1 або 2): </label>
<input type="number" id="counterIncrement" value="1">
<button id="applyIncrement">Застосувати інкремент</button>
</div>
<br>
<div class="result">
<ul id="counterList">
<li>Елемент списку 1</li>
<li>Елемент списку 2</li>
<li>Елемент списку 3</li>
<li>Елемент списку 4</li>
<li>Елемент списку 5</li>
</ul>
</div>
</main>
body {
font-size: 16px;
line-height: 1.5;
font-family: monospace;
}
header {
background-color: #f1f1f1;
margin-bottom: 25px;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
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);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
ul {
counter-reset: list-counter;
}
li {
list-style: none;
counter-increment: list-counter;
margin-bottom: 5px;
}
li::before {
content: counter(list-counter) ". ";
font-weight: bold;
}
document.getElementById('applyIncrement').addEventListener('click', function() {
let incrementValue = document.getElementById('counterIncrement').value;
let listItems = document.querySelectorAll('#counterList li');
listItems.forEach(item => {
item.style.counterIncrement = `list-counter ${incrementValue}`;
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.