jQuery:在$('selector')内放一个变量和一个选择器? [英] jQuery : put a variable AND a selector inside the $('selector')?

查看:140
本文介绍了jQuery:在$('selector')内放一个变量和一个选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您告诉我是否可以使用这样的选择器:

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

$(s_li,'#tools')

$(s_li, '#tools')

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?

非常感谢.

推荐答案

如果s_li是选择器字符串:

If s_li is a selector string:

$(s_li + ', #tools')

如果s_li是对DOM元素的引用:

If s_li is a reference to a DOM element:

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

这篇关于jQuery:在$('selector')内放一个变量和一个选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆