码迷,mamicode.com
首页 > Web开发 > 详细

轉:Jquery绑定img的click事件

时间:2014-09-22 18:27:42      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:style   io   sp   问题   cti   on   c   log   代码   

用JQUERY给IMG element绑定click事件的时候,直接用img.click(function(){...})不起作用,如下面代码
$("img.ms-rteImage-LightBox").click(function(){         
    SP.UI.ModalDialog.showModalDialog({ 
        url: $(this).attr("src"), 
        title: $(this).attr("alt") 
    }); 
});

解决这个问题需要用jquery里面bind函数去附加click event. 如下:

$("img.ms-rteImage-LightBox").bind("click",function(){         
    SP.UI.ModalDialog.showModalDialog({ 
        url: $(this).attr("src"), 
        title: $(this).attr("alt") 
    }); 
});

轉:Jquery绑定img的click事件

标签:style   io   sp   问题   cti   on   c   log   代码   

原文地址:http://www.cnblogs.com/Koy/p/3986197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!