Paul
Paul

Reputation: 6176

jQuery : put a variable AND a selector inside the $('selector')?

could you please tell me if it's possible de use a selector like that :

$(s_li, '#tools')

s_li is a variable, and '#tools' is the selector, i'd like to bind an event to both of those targets. My exemple doesn't work, do you any idea?

Thanks a lot.

Upvotes: 0

Views: 532

Answers (2)

Šime Vidas
Šime Vidas

Reputation: 186063

If s_li is a selector string:

$(s_li + ', #tools')

If s_li is a reference to a DOM element:

$(s_li).add('#tools')

Upvotes: 8

Tony
Tony

Reputation: 933

You can do $('#selector1, #selector2')...

http://api.jquery.com/multiple-selector/ For more detail.

Upvotes: 0

Related Questions