user1765862
user1765862

Reputation: 14165

Multiple elements wired to function

if I have multiple elements which are wire certain function like

$('#one').change(function () {
    myFun();
});
$('#two').change(function () {
    myFun();
});

how can I do this with inline statement, I tried with

$('#one', '#tow').change()...

but that obviously doesn't work.

Upvotes: 1

Views: 42

Answers (2)

Emir Marques
Emir Marques

Reputation: 2687

Use this:

$('#one, #tow').change()...

Upvotes: 2

Oleksandr T.
Oleksandr T.

Reputation: 77502

For several selectors you can use comma (,), like this

$('#one, #tow').change()

multiple selector

Upvotes: 4

Related Questions