id和變量名都可以,怎么才規范?為什么?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>style樣式</title>
</head>
<body>
? <h2 id="con">I love JavaScript</H2>
? <p> JavaScript使網頁顯示動態效果并實現與用戶交互功能。</p>
? <script type="text/javascript">
? ? var mychar= document.getElementById("con");
? ? mychar.style.color="red";
? ? mychar.style.fontSize="38px";
? ? mychar.style.backgroundColor="#CCC";
? ? mychar.style.width="300px";
? ??
? ? var abc=document.getElementById("con");
? ? abc.style.color="blue";
? ? con.style.fontSize="18px";
? ? con.style.backgroundColor="red";
? ? abc.style.width="150px";
? </script>
</body>
</html>
2016-10-18
id只能有一個,變量名可以傳入任何類型的值
2016-10-18
沒懂你想問什么問題,和這段代碼又有什么關系。。。