日期:2014-05-16 浏览次数:20380 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> </head> <body> <div id="a"> <span> 1 <span> 2 <span>3</span> </span> </span> </div> <div id="b"> <span> 1 <span> 2 <span>3</span> </span> </span> </div> <script> alert( $('#a').children('span').length ) //1 alert( $('#a').find('span').length ) //3 </script> </body> </html>