jQuery获取子元素个数的方法

1 //获取id=div1下的子元素的个数
2 $('#id').children().length;
3 //获取id=div1下的p元素个数
4 $('#id').children('p').length;