Skip to content

Day 4: Events & addEventListener

Listen for user input and interactions with addEventListener and inspect event details.

const btn = document.querySelector('#action-btn');
btn.addEventListener('click', event => {
console.log('Button clicked!', event.target);
});
const input = document.querySelector('#name-input');
input.addEventListener('input', e => {
console.log('Current value:', e.target.value);
});
  1. Create a live character counter that updates a <span> in real-time as a user types into a <textarea>.