怎么样得到<UL>下面有多少具<li>
怎么样得到<UL>下面有多少具<li>??
[解决办法]
<!DOCTYPE HTML><html> <head> <meta charset="gb2312" /> <title></title> <style> </style> </head> <body> <ul id="test"> <li>1-1</li> <li>1-1</li> <li>1-1</li> <li>1-1</li> <li>1-1</li> <li>1-1</li> </ul> <script> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } function $t(name, cot){ cot = cot || document; return cot.getElementsByTagName(name); } alert( $t('li', $('test')).length ) </script> </body></html>
[解决办法]
UL有什么标识 ID? NAME? CLASS?
JQuery:
$("ul").find("li").length;
[解决办法]