From the course: JavaScript Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Practice: Modify classes and attributes, and styles - JavaScript Tutorial
From the course: JavaScript Essential Training
Practice: Modify classes and attributes, and styles
- Being able to quickly access, modify, add and remove classes, attributes and inline styles from any element in the DOM, is a bit like having a bag of tools on hand to solve pretty much any problem. Need to indicate a state change of an element? Add or remove a class. Need to pass data from one element to the other? Add a data attribute. Need to change the appearance of a specific element for some reason? Add an inline style. In the previous practice assignment, you familiarized yourself with accessing DOM elements using the query selector and query selector all methods. Now I want you to take this one step further by actively modifying the elements you've targeted by adding or removing classes, attributes, and inline styles. Here's some examples of what you can do. Find an element and add two different classes then remove only one of those new classes. Add a new attribute to an element. This can be a standard…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
DOM: The Document Object Model4m 7s
-
(Locked)
Access elements with querySelector methods6m 6s
-
(Locked)
Access elements using older methods3m 45s
-
(Locked)
Practice: Find an element1m 29s
-
(Locked)
Modifying element classes4m 53s
-
(Locked)
Attributes4m 13s
-
(Locked)
Inline style3m 52s
-
(Locked)
Practice: Modify classes and attributes, and styles1m 36s
-
(Locked)
Add DOM elements5m 25s
-
(Locked)
Challenge intro: Create elements1m 17s
-
(Locked)
Solution: Create elements3m 35s
-
-
-
-
-
-
-