开发者

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

开发者 https://www.devze.com 2023-02-24 10:19 出处:网络
could you ple开发者_运维技巧ase tell me if it\'s possible de use a selector like that : $(s_li, \'#tools\')

could you ple开发者_运维技巧ase 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.


If s_li is a selector string:

$(s_li + ', #tools')

If s_li is a reference to a DOM element:

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


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消