DOM Manipulation

parentElement

parentElement

Traversal means moving from one DOM node to a related node. parentElement moves from an element to the element that contains it.

This is useful when the specific thing you can select is inside the thing you need to update. For example, an icon, label, or count may identify the row, but the row is what needs the state class.

Your task: Select the overdue badge, move to its parent task row, and add the needs-attention class to that row.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

parentElement

Traversal means moving from one DOM node to a related node. parentElement moves from an element to the element that contains it.

This is useful when the specific thing you can select is inside the thing you need to update. For example, an icon, label, or count may identify the row, but the row is what needs the state class.

Your task: Select the overdue badge, move to its parent task row, and add the needs-attention class to that row.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.