Jump to content

List multiple classes for jQuery events

venomtail
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?

Desktop: 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 - RMx 750 W 80+ Gold - Manta - Silent Wings Pro 4's enjoyer

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

Current build on PCPartPicker

 

Link to comment
Share on other sites

Link to post
Share on other sites

Selectors are the same as if it was CSS:

$('.table_1, .table_2, .table_3')
Link to comment
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

×