Hierarchic Indeterminate Checkboxes with JavaScript (Vanilla)

Earlier today Chris Coyier tweeted that he was in the process of rewriting one of his pens without jQuery:

Sparked by his tweet I decided to fork his pen and try to do it myself. Here’s the result:

A fun exercise if I say so myself, even though I’m not 100% satisfied with the manual traversal I needed to do (.parentElement.parentElement — really?). Perhaps there’s a better way to do this?

Did this help you out? Like what you see?
Consider donating.

I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!

☕️ Buy me a Coffee ($3)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.