點按鈕沒效果啊,求大神幫我看看哪里錯了,找了好久都沒找到bug
<!DOCTYPE html>
<html>
<head>?
<meta charset="utf-8">?
<style type="text/css">
#div1{
? ? height:300px;
? ? width:500px;
? ? background-color:lightblue;
? ? color:black;
? ? margin:100px auto;
}
</style>
</head>
<body>
<div id="div1">
? ? <p>雖然我也不知道輸入什么</p>
? ? <p>那我就瞎他媽寫一寫吧</p>
? ? <p>哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈。</p>
</div>
<form>
<input type="button" onclick="color()" value="改變顏色">
<input type="button" onclick="wh()" value="改變寬高">
<input type="button" onclick="hh()" value="隱藏">
<input type="button" onclick="see()" value="顯示">
<input type="button" onclick="hde()" value="取消設置">
</form>
<script type="text/javascript">
? ? function color(){
? ? ?var d=document.getElementById("div1"); ??
? ? ?d.style.color="red";
? ? ?d.style.background-color="green";
? ? }
//改變顏色
? ? function wh(){
? ? ? ? var div1=document.getElementById("div1");
? ? ? ? div1.style.width="800px";
? ? ? ? div1.style.height="200px";
? ? //改變寬高
? ? }
? ? function hh{
? ? ? ? var div1=document.getElementById("div1");
? ? ? ? div1.style.display="none";
? ? }//隱藏
? ? function see(){
? ? ? ? var div1=document.getElementById("div1");
? ? ? ? div1.style.display="block";
? ? }//顯示
? ? function hde(){
? ? ? ?var div1=document.getElementById("div1");
? ? ? ? var x=confirm("是否取消設置?");
? ? ? ? if(x==true){
? ? ? ? ? ? div1.style.height="300px";
? ? div1.style.width="500px";
? ? div1.style.background-color="blue";
? ? div1.style.color="black";
? ? div1.style.margin="100px auto";
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? alert("不要搞事情");
? ? ? ? }
? ? }//取消設置
</script>
</body>
</html>
2017-07-31
background-color ? ? ? ? ? ? ?改為:backgroundColor ? ? ? hh函數少了 () ? ? ? ? ? ?加油!!!!加油!!!!