Windows/jquery

jquery attr() 사용 (이미지변경)

아로스 2010. 7. 22. 13:04

<img id="imImg" src="1.gif">

$("#imImg").attr("src","2.gif");

$("#imImg").bind("click",function(){
 $("#imImg").attr("src","3.gif");
 });

$("img".bind("click",function(){
 var src=($(this).attr("src") == "3.gif")
  ? "1_on.gif"
  : "1_on.gif";
 $(this).attr("src",src);
});