开发者

Full selector string or this.find and selector string

开发者 https://www.devze.com 2023-01-31 22:13 出处:网络
Both work, but is there any advantage / dis-advantage of using one over the other ? 开发者_如何学Python

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

精彩评论

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