Goal
Modify the previous script to announce the current count to screen reader users as it changes.
Project
You’ve written 0 words and 0 characters.
View Source
(function() {
let elText = document.querySelector( "#text" );
let elStatus = document.querySelector( "#status" );
elText.addEventListener( "input", e =>
{
let charCount = e.target.value.length;
let wordCount = e.target.value.trim()
.split( /\s+/g )
.length;
elStatus.innerHTML = `You’ve written <strong>${wordCount} words</strong> and <strong>${charCount} characters</strong>.`;
});
})();
Projects
- Toggle Password Visibility
- Toggle Multiple Password Fields
- Toggle Passwords in Multiple Forms
- Character Count
- Character and Word Count
- Announcing the Count
- Random Ron
- Random Ron Without Duplicates
- New York Times Top Stories
- New York Times Multiple Categories
- Sanitizing the NYT API Data
- Monster Shuffle