feat: implement item selection functionality in exercise 3

This commit is contained in:
2026-05-20 16:13:14 -03:00
parent b97fb32d67
commit e7d0ca8aa2
3 changed files with 36 additions and 2 deletions

View File

@@ -20,3 +20,15 @@ const charCount = document.getElementById('charCount');
textInput.addEventListener('input', () => {
charCount.textContent = textInput.value.length;
});
// Ejercicio 3
const itemList = document.getElementById('itemList');
itemList.addEventListener('click', (event) => {
if (event.target.tagName === 'LI') {
const items = itemList.querySelectorAll('li');
items.forEach(item => item.classList.remove('selected'));
event.target.classList.add('selected');
}
});