<div class="box"> <div class="item"> <div class="out"> <div class="inside"> 666 </div> </div> </div> </div> <script> var one = $('.box').children().attr('class'); //item var two = $('.box').children().find('.out').attr('class');//out var three = $('.inside').parent().attr('class'); //out var four = $('.inside').parents('.item').attr('class') //item </script>
1.選擇直接父子元素:
$(e).parent();
$(e)children()
2.選擇多級父子元素:
父:$(e).parents('.box');
子:$(e).children().find('.inside');
3.jquery 對象轉 dom
$(e).get(0);