开发者

combine two jquery select statements

开发者 https://www.devze.com 2023-03-04 17:04 出处:网络
how can i merge the 开发者_StackOverflowresults of two select statments with jquery? for example i have

how can i merge the 开发者_StackOverflowresults of two select statments with jquery?

for example i have

var previous = $(this).prev('td');
var next = $(this).next('td');

how do i then combine the two sets of results into one?


var all = $.merge(previous, next);


Try:

var all=$(this).prev('td').add( $(this).next('td') );


You can use empty collection

var previous = $(this).prev('td'),
    next = $(this).next('td'),
    buttons = $().add(previous).add(next);

Example: http://jsfiddle.net/UBnMm/

Alternatively:

var buttons = $(this).prev('td').add($(this).next('td'));


I think you are looking for $(this).siblings('td')

0

精彩评论

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