css怎么实现点击切换图片

html-css026

css怎么实现点击切换图片,第1张

<div class="gyyy">

<img src="关于医院.jpg">

<span>关于医院</span>

</div>

$(function(){

var imgs=document.getElementsByName("img")

$(".gyyy").click(function(){

imgs.src="新图片的路径";

$(".gyyy>span").css("color","blue")

})

})

使用jquery的toggle方法进行图片切换\x0d\x0a$(function(){\x0d\x0a$("#h1").toggle(function(){\x0d\x0a$("#h1").css("background-image","路径('./20110528073501b54e6.jpg')")\x0d\x0a},function(){\x0d\x0a$("#h1").css("background-image","路径('./2011060708410874041.jpg')")\x0d\x0a})\x0d\x0a}) \x0d\x0a\x0d\x0a\x0d\x0a \x0d\x0aCSS\x0d\x0a.hh1{\x0d\x0abackground: url("./2011060708410874041.jpg")\x0d\x0awidth: 120px\x0d\x0aheight: 90px\x0d\x0a}