Jump to content

List multiple classes for jQuery events

Go to solution Solved by riklaunim,

Selectors are the same as if it was CSS:

$('.table_1, .table_2, .table_3')

To keep code simple and scalable, I'm hoping there's a way to list multiple classes inside jQuery events. I've got 3 inputs I want to have code listen to.

I've tried:

$('.table_1','.table_2','.table_3').on('focusout', function () { //
    alert("multi on focusout");
});

and

$('.table_1 .table_2 .table_3').on('focusout', function () { //
    alert("multi on focusout");
});

 

I feel like I'm close and this is the way it's meant to work in functionality, I just don't have the proper identifiers to let jQuery know I'm listing multiple classes into one event. What is the correct way of identifying this?

MAIN: Ryzen 7 5800X3D - Kraken X62 Rev 2 - STRIX X470-I - 3600MHz 32GB Kingston Fury - 250GB 970 Evo boot - 2x 500GB 860 Evo - 1TB P3 - 4TB HDD - RX6800 - Antec HCG Platinum - Manta - Silent Wings Pro 4's enjoyer

SetupZowie XL2740 27.0" 240hz - Roccat Burt Pro OG Corsair K70 browns - PC38X - Mackie CR5X's Mackie CR8S-XBT

Current build on PCPartPicker

 

 

HTPC: Ryzen 7 2700X - BeQuiet! Shadow Rock 3 - STRIX X570-F - 3200MHz 32GB Corsair Dominator - 250GB Exceria boot - 500GB SN730 - 1TB Sandisk 3D - 4TB HDD - Limited Edition Vega 64 - Corsair RM750x 80+ Gold - North - Alphacool Apex Stealth Metal - BeQuiet! Light Wings

SetupHisense 55E7NQ - Hisense HS205G

HTPC on PCPartPicker

Link to comment
https://linustechtips.com/topic/1529751-list-multiple-classes-for-jquery-events/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×