读书人

jquery img的click事件不起作用解决方

发布时间: 2012-11-10 10:48:51 作者: rapoo

jquery img的click事件不起作用
RT

<!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=utf-8" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.lazyload.js" type="text/javascript"></script>
<script type="text/javascript">

/*$(".small").hover(function(){
$("http://v.pp.cn/static/img/index_big.png").lazyload();
},function(){});*/

/*$(".small").click(function(){
$(this).attr('src', "http://v.pp.cn/static/img/index_big.png");
});*/

$("img.small").bind("click",function(){
alert(1);
$(this).attr('src', "http://v.pp.cn/static/img/index_big.png");
});
</script>
<img src="http://testv.pp.cc/static/img/no_photos.jpg"> <br>
<img src="http://testv.pp.cc/static/img/d.jpg"> <br>
<img class="small" id="small" src="http://testv.pp.cc/static/img/s.jpg"> <br>


[解决办法]
$(document).ready(function() {

$("img.small").bind("click",function(){
alert(1);
$(this).attr('src', "http://v.pp.cn/static/img/index_big.png");
});
});

读书人网 >JavaScript

热点推荐