这是Jquery代码:
$(function () { $("#h1").toggle(function () { $("#h1").css("background-image", "url(‘./20110528073501b54e6.jpg‘)"); }, function () { $("#h1").css("background-image", "url(‘./2011060708410874041.jpg‘)"); }) })
html代码:
<html> <head> <title></title> </head> <body> <input type="button" value="huan" id="h1" class="hh1" /> </body> </html>
$(function(){
$("#h1").toggle(function(){
$("#h1").css("background-image","url(‘./20110528073501b54e6.jpg‘)");
},function(){
$("#h1").css("background-image","url(‘./2011060708410874041.jpg‘)");
})
})
Jquery 点击按钮将其背景图换成另一张,再次点击恢复默认图片
原文:http://www.cnblogs.com/LoveQin/p/4779601.html