javascript更换button背景图片效果

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="D1.aspx.cs" Inherits="D1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>
  <title> javascript更换button背景图片效果</title>

   <style type='text/css'>
  .bg{
     background-image:   url("http://www.loveqiutian.cn/images/IT984/index_logo.gif");cursor: pointer;  width:153px; height:52px; border:0;
     }
  .bg1{
     background-image:   url("http://www.baidu.com/img/sslm1_logo.gif");cursor: pointer;  width:153px; height:52px; border:0;
     }
 </style>
 </head>
 <body>
  <form action=''>
  <input type="button" name="subSort"  id="subSort"  class="bg" onclick="javascript:if(confirm('是否更换背景图片'))this.className=(this.className=='bg')?'bg1':'bg';"/>
  </form>
 </body>
</html>

posted @ 2008-08-12 10:46  hongzk  阅读(3305)  评论(0编辑  收藏  举报