css如何实现点击按钮变换背景图片

发布时间:2012-02-06 01:27:33
<html>
<head>
<style>
.a { background:#F00; }
.b { background:#0F0; }
</style>
<script>
var i = 0;
function change()
{
 if (i) {
 document.getElementById("btn").className="a";
 i=0;
 }
 else{
  document.getElementById("btn").className="b";
  i=1;
 }
}
</script>
</head>
<body>
<input id="btn" type="button" class="a" value="click me" onClick="change()">
</body>
</html>

点击量:

上一篇:IE里为什么不居中?
下一篇:css中div高度自适应
你可能也感兴趣