开发者

Full selector string or this.find and selector string

Both work, but is there any advantage / dis-advantage of using one over the other ?

开发者_如何学Python
$("#" + this.id + " > ul > li.active:first")

vs

$(this).find(" > ul > li.active:first")


The second selector works, I'd go with that instead of concatenating the ID into the first selector (looks ugly) and making jQuery look for that same element ID again (redundant).


You could also do this... I think.

$(" > ul li.active:first", this);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜