标签:script onclick cti div javascrip black red change name
<html> <head> <title>gallery</title> <style> .change{ background:red; } .change2{ background:black; } </style> </head> <body id="body1" class="change" onclick="changeColor()"> </body> </html> <script> function changeColor(){ var style = document.getElementById("body1").className; if(style=="change"){ document.getElementById("body1").className = "change2"; }else{ document.getElementById("body1").className = "change"; } } </script>
小练习,点击背景改变颜色。
标签:script onclick cti div javascrip black red change name
原文地址:https://www.cnblogs.com/hekiraku/p/12363055.html