我可以在 jQuery 中使用 $(this) 和 css 选择器吗?

Can I use $(this) along with a css selector in jQuery?

我可以将 $(this) 与 css 选择器一起使用吗?

例如,如果我想执行以下操作:

$(".toggle-nav").on("click", function(){
    $(".nav").toggleClass("active");
    $(this).toggleClass("active");
});

有什么方法可以缩短为以下或类似的内容吗?

$(".toggle-nav").on("click", function(){
    $(this|".nav").toggleClass("active");
});

我知道我可以做这个或类似的事情:

$(".toggle-nav").on("click", function(e){
    element = e.currentTarget;
    // get selector from e.currentTarget ...
    $("#"+element.id+",.nav").toggleClass("active");
});

但是有jQuery方法吗?

Is there any way that be shortened to the following or anything similar?

使用jqueryadd

$(this).add( ".nav" ).toggleClass("active");