1.children()只会返回元素节点
2.contents()还可以返回文本节点
3.实例:
1 <ul id="n1"> 2 test 3 <li id="n2" class="active"> 4 <span id="n3">菜单1</span> 5 <ul id="n4"> 6 <li id="n5" class="active">子菜单1-1</li> 7 <li id="n6">子菜单1-3</li> 8 </ul> 9 </li> 10 <li id="n7"> 11 <span id="n8">菜单2</span> 12 <ul id="n9"> 13 <li id="n10">子菜单2-1</li> 14 <li id="n11" class="active">子菜单2-2</li> 15 <li id="n12">子菜单2-3</li> 16 </ul> 17 </li> 18 <li id="n13"><span id="n14">菜单3</span></li> 19 </ul>
children():
contents():
时间: 2024-12-24 08:05:05