toggle兑现图片切换
toggle实现图片切换
<!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> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script type="text/javascript" src="js/jquery-1.4.2.js"></script> <style type="text/css"> body{ font-size:14px;} img{ border:1px solid #ccc; padding:3px;} </style> <script type="text/javascript"> $(function(){ $("img").toggle(function(){ $("img").attr("src","images/01.png"); $("img").attr("title",this.src); },function(){ $("img").attr("src","images/02.png"); $("img").attr("title",this.src); },function(){ $("img").attr("src","images/03.png"); $("img").attr("title",this.src); }) }) </script> </head> <body> <img /> </body> </html>