Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How do I only target one instance of a class? Reply To: How do I only target one instance of a class?

#158363
__
Participant

don’t have a common parent.

Well, I guess “ancestor” is a better term. …looks like div.grid is the closest. You could even use the document if you wanted to; events bubble that high.

nevermind

Actually, now that I’m looking closer (and hopefully, understanding better), you could attach the handler to your .cards. It would be easier, though, if you had a data-* attribute to tie each button directly to the content it controls.

demo