1. 程式人生 > >classname在JavaScript中的應用

classname在JavaScript中的應用

.get nbsp .com utf put java 標題 width bsp

<html>
<head>
<meta charset="utf-8">
<title>無標題文檔</title>
<style type="text/css">
    #div1 {
        width: 100px;
        height: 100px;
        border: 1px solid red;
    }
    .box {background:red;}
</style>
<script>
    function bianse(){
        var odiv
=document.getElementById(div1); odiv.className=box; } </script> </head> <body> <input type="button" value="變色" onClick="bianse()" /> <div id="div1"> </div> </body> </html>

查看原文

classname在JavaScript中的應用