亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么我點一鍵換膚沒有反應

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

*{margin:0; pading:0;}

.dh{ height:30px; width:800px; list-style: none; background: red;}

.dh li a{

display: block;

float:left;

height:30px;

line-height:30px;

width:100px;

background: #fc6;

text-align: center;

color:green;

text-decoration:none;

}

.dh li a:hover{

background: #DBE6FD;

color:#999;

}

.h{ height:30px; width:700px; list-style: none;}

.h li a{

display: block;

float:left;

height:30px;

line-height:30px;

width:100px;

background:#E3E0D5;

text-align: center;

color:green;

text-decoration:none;

}

.h li a:hover{

background: #DBE6FD;

color:#999;

}


? ? }

</style>

</head>

<body>

<ul id="hh">

<li><a href="#">首頁</a></li>

<li><a href="#">新聞</a></li>

<li><a href="#">音樂</a></li>

<li><a href="#">貼吧</a></li>

<li><a href="#">知道</a></li>

<li><a href="#">政治</a></li>

<li><a href="#">經濟</a></li>

</ul>

<input type="button" value="一鍵換膚" onclick="newColor()"/>

<script type="text/javascript">

function newColor()

{

// alert("年后");

var newUl=document.getElementById("hh");

newul.className="h";

}


</script>

</body>

</html>


正在回答

2 回答

錯誤地方:

function newColor()

{

// alert("年后");

var newUl=document.getElementById("hh");

newul.className="h";

}

原:newul.className="h";

改:newUl.className="h";

原因:其實,你就是把變量的名字寫錯了而已。。(這里我只能感嘆一句,命名規則很重要。)

0 回復 有任何疑惑可以回復我~
#1

唯爾半截湘妃 提問者

very much!我自己找了半天都沒找到!
2016-07-08 回復 有任何疑惑可以回復我~

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

*{margin:0; pading:0;}

.dh{ height:30px; width:800px; list-style: none; background: red;}

.dh li a{

display: block;

float:left;

height:30px;

line-height:30px;

width:100px;

background: #fc6;

text-align: center;

color:green;

text-decoration:none;

}

.dh li a:hover{

background: #DBE6FD;

color:#999;

}

.h{ height:30px; width:700px; list-style: none;}

.h li a{

display: block;

float:left;

height:30px;

line-height:30px;

width:100px;

background:#E3E0D5;

text-align: center;

color:green;

text-decoration:none;

}

.h li a:hover{

background: #DBE6FD;

color:#999;

}


? ? }

</style>

</head>

<body>

<ul id="hh" class="dh">

<li><a href="#">首頁</a></li>

<li><a href="#">新聞</a></li>

<li><a href="#">音樂</a></li>

<li><a href="#">貼吧</a></li>

<li><a href="#">知道</a></li>

<li><a href="#">政治</a></li>

<li><a href="#">經濟</a></li>

</ul>

<input type="button" value="一鍵換膚" onclick="newColor()"/>

<script type="text/javascript">

function newColor()

{

// alert("年后");

var newUl=document.getElementById("hh");

newul.className="h";

}


</script>

</body>

</html>


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么我點一鍵換膚沒有反應

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號