| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | Current Level: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
Add meaningful IDs to all elements and test that they can be accessed.
id attributes to all elements (input, button, card, etc.)getElementById() in the consolesetProperty() to test that you can modify element propertiesNeed help with IDs? Check out these snippets:
console.log(document.getElementById("your-id")) to test accessdocument.getElementById("your-input-id") and press EntersetProperty() to test element modification:
setProperty("your-input-id", "backgroundColor", "yellow")setProperty("your-button-id", "border", "3px solid red")null, check that the ID is spelled correctly in your HTMLFor extra practice, you can also test element access with:
console.log(document.getElementById("your-input-id"))
This will show you the full element object in the console, which can help you understand what properties and methods are available.
You can also use the native DOM style property to modify elements directly:
// Same as setProperty("your-input-id", "backgroundColor", "yellow")
document.getElementById("your-input-id").style.backgroundColor = "yellow";
// Same as setProperty("your-button-id", "border", "3px solid red")
document.getElementById("your-button-id").style.border = "3px solid red";
The DOM Operations approach is the standard way to manipulate styles in professional JavaScript development and is used across all major frameworks and libraries. Learning the native DOM API prepares you for real-world codebases where helper functions aren’t available.
| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | Current Level: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |