为什么我对着书上敲的代码 没有效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>呵呵哒</title>
</head>
<body>
<p title="asaaads"></p>
<p title="dhghddjshd"></p>
<script>
var pig=document.getElementByTagName("p");
alert(pig.length);
for(var i=0;i<pig.length;i++){
alert(pig[i].getAttribute("title"));
}
</script>
</body>
</html>
这段代码 本想实现get title 里面的属性值 可是没用 为什么?