Reputation: 4292
Is it possible to select the children of a sibling of the current context in jQuery using a single expression similar to this?
$('~ div > span', this)
Unfortunately this does not work for me so I don't believe jQuery supports this type of chaining in an expression. I was however able to get the following methods to work:
$('> span', $('~ div', this))
$(this).siblings('div').children('span')
I am looking for a way to get the children of a sibling using the following API call, or for an explanation on why it is not possible:
jQuery( expression, context )
Upvotes: 4
Views: 7715
Reputation: 516
I know this is a bit old but figured I'd answer in case anyone else is trying to do this. find() is the best way to do this
$(this).siblings('div').find('span');
Hope that helps
Upvotes: 6
Reputation: 35107
Try using $(this).next('div').children('span')
http://docs.jquery.com/Traversing/next
Upvotes: 0