jquery 选择多级父子元素
<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);
自律使我自由