开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜