.next
selects the immediate next sibling of the selected element, i.e the .slidingDiv
element(if it matches with the specified selector), you can use .find()
and .next()
methods:
var iframe = $(this).next('.slidingDiv').find('.myiFrame');
If you want to select all the .myiFrame
descendant elements of all the next sibling .slidingDiv
elements you can either use .siblings()
or .nextAll()
methods:
$(this).nextAll('.slidingDiv').find('.myiFrame').attr('src', function(){
return $(this).data('src');
});