【问题标题】:jquery multiple selectors including 'this' - best clean syntaxjquery 多个选择器,包括“this”——最好的简洁语法
【发布时间】:2011-05-23 14:00:58
【问题描述】:

所以我知道你可以像这样使用多个选择器

$("#div_1 , #div_2").doStuff......

但是

我想选择“this”(基于翻转功能)和页面上的另一个元素。

我尝试了很多方法,但似乎无法使其正常工作。

$("this , #div_2").doStuff......//not working // 
$(this ", #div_2").doStuff......//not working // 
$(this" #div_2").doStuff......//not working // 

看起来很简单,但仍然无法使用。

提前致谢

S

【问题讨论】:

    标签: jquery jquery-selectors this


    【解决方案1】:

    你可以使用add()方法:

    $(this).add("#div_2").doStuff();
    

    【讨论】:

    • 哇 - 不到 2 分钟就回答 - 看了 11 次,一定很喜欢所以 - 谢谢你的回答!
    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    相关资源
    最近更新 更多