开发者

jQuery: Multiple selectors including this

i want to sel开发者_运维百科ect ´this´ and something else. for example:

$(this + ', ' + this + ' > div')

how can i make this work? Is this possible in a single selector?


You can use .andSelf() to hop back in the chain and include the element before as well, like this:

$(this).children("div").andSelf()

So we go from this to it's children, then .andSelf() adds to that collection what was in the chain before, which was this.


You can add a result to another:

$(this).add('div', this)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜