不知道對不對
//定義"改變顏色"的函數(shù) var Oh2 = document.getElementById('con'),Obtn = document.getElementById("btn1"),Otxt = document.getElementById("txt"); Obtn.onclick = function fn(){ ? ?Oh2.style.color = "red"; ? ?Otxt.style.backgroundColor = "blue"; } 也不知道對不對。反正提交了,慕課網(wǎng)的也不能運行,是不是有 bug??
2016-12-31
你可以試試其他的運行軟件看看?;蛘哂糜浭卤究纯?。
我的問題:1、你用Obtn.onclick的意思是什么?
2、你的第一個?Oh2 = document.getElementById('con'),里面應(yīng)該是用雙引號,你好像用的是單引號。
我用vs試了試,下面是我改你的代碼你看看吧!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
?function change(){?
? var ch2 = document.getElementById("con");
? var ctxt = document.getElementById("txt"); ??
? ?ch2.style.color = "red"; ? ?
? ?ctxt.style.backgroundColor = "blue";?
}?
</script>
</head>?
<body>
<p id="con">this</p>
<p id="txt">is</p>
<input type="button" value="test" onclick="change()"/>
</body>
</html>?