日期:2014-05-16 浏览次数:20335 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>找错</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
</style>
</head>
<body>
<div id="banner">
<p>p1</p>
<p>p2
<span>
<p>我是span下面的P1</p>
<p>我是span下面的P2</p>
</span>
</p>
<span>span</span>
<div>div子</div>
</div>
<div>
第3个
</div>
<script type="text/javascript">
function t1(){
var find_id_banner = document.getElementById('banner');
var find_tag_p = find_id_banner.getElementsByTagName('p');
var find_tag_span = find_tag_p[1].getElementsByTagName('span');
var find_tag_span_p = find_tag_span[0].getElementsByTagName('p');
alert(find_tag_span_p.length);
}
</script>
<p>
<input type="button" value="查找" onclick="t1();" />
</p>
</body>
</html>