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?


Just out of curiosity, did you pull this from the Github repo?

What repo? I could fix this up and make a pull request, if you think it’s worth it.

This is basically just a jQuery-plugin-like pattern: setting up a private scope to hold all the vars you’ll need, then iterating over each $ object and setting things up. I actually didn’t realize until halfway through writing that that setting the event listeners on the .card, and then delegating to the buttons, would automatically give each card its own “context.” Worked out pretty nice.

Do you still want comments?

I’m not usually particularly successful with javascript; I’m a php guy. But I’m trying, and I’ve been wrestling with require.js for a few days now, so I guess I’m “in the zone.”

Yeah, I didn’t notice the “pin.” Looks like you figured it out!

I always appreciate the help man. Thank you so much!

No problem at all. Happy to help.

1270 Replies created

F***, how many? geez, I need to get a life