<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>getAttribute</title>
<!--為div設置基本樣式-->
<style?type="text/css">
div{
color:red;
background:?green;
width:150px;
height:?100px;
border:1px?solid
}
</style>
<script?type="text/javascript">//三種方法檢索元素節點,并通過節點改變背景顏色
function?add(){
var?A=document.getElementById("com")
A.style.groundback="yellow"
}
function?bdd(){
var?B=document.getElementsByName("con")
B.style.groundback="yellow"
}
function?cdd(){
var?C=docnment.getElementsByTagName("button")
C[1].style.groundback="yellow"
}
</script>
</head>
<body>
<div?name="con"?id="com">1</div>
<div?name="con"?>1</div>
<div?name="con"?>3</div>
<button?onclick="add()">通過id改變背景顏色</button>
<button?onclick="bdd()">通過name改變背景顏色</button>
<button?onclick="cdd()">通過tagname改變背景顏色</button>
</body>
</html>
求前輩指點,代碼錯誤在哪?
我要沖錢
2016-12-01 21:39:43