3-6:className到底哪里出錯了呢???
<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"/>
<title>classname</title>
<style>
body{?font-size:16px;}
.dm{
????border:1px?solid?#bbb;
????width:200px;
????height:50px;
????background:rgb(20,?30,?168);
????color:red;
}
.dn{
????border:2px?solid??rgb(1,?9,?17);
????width:200px;
????height:50px;??
????color:greenyellow;
????background:rgb(214,?28,?183)
}
</style>
</head>
<body>
<p?id="m1">
????hello?world
</p>
<input?type="button"?value="樣式"?onclick="abc"/>
<p?id="m2">
????I?love?javascript
</p>
<input?type="button"?value="外觀"?onclick="edf"/>
<script?type="text/javascript">
function?abc(){
????var?m3=document.getElementById("m1");
????m3.className="dm";
}
function?edf(){
????var?m4=document.getElementById("m2");
????m4.className="dn";
}
</script>
</body>
</html>
這個是我自己寫的改變class屬性代碼,和課程教的都是一樣的,為什么在瀏覽器上打開就沒有效果了??有木有大神詳細講解一下,謝謝了??!
2020-04-22
onclick="abc()"??onclick="edf()",這樣才可以哦
2020-08-02
沒有括號?按鈕的事件
2020-06-23
單擊事件的括號呢??
2020-04-22
onclick綁定的方法要加括號