怎么样得到<UL>下面有多少具<li>
怎么样得到<UL>下面有多少具<li>??
------解决方案--------------------
HTML code<!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;
------解决方案--------------------
查询谷 - www.chaxungu.com
如何样得到<UL>下面有多少具<li>
编辑:chaxungu时间:2022-10-02 23:15:13分类:web开发