日期:2014-05-16 浏览次数:20420 次
<!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;
------解决方案--------------------