开发者

.click() on image does not work as expected

I am attempting to alert some text when an image is clicked.

javascript code:

$(document).ready(function() {
    $(".delRo开发者_运维技巧w").click('function() {
        alert("hello!");
    });
});  

html code:

<img src="../images/delete.png" alt="delete" class="delRow"></img>

This code seems straight forward; however, it is not working as expected. Are images handled differently when using .click?

-Thanks,

Rich


$(document).ready(function() {
    $(".delRow").click(function() {
        alert("hello!");
    });
});

WORKING DEMO


You have extra ' at click.(function(){

It should be

$(document).ready(function() {
    $(".delRow").click(function() {
        alert("hello!");
    });
});  


$(document).ready(function() {
    $(".delRow").click(function() {
        alert("hello!");
    });
}); 

Remove the " ' " before the second function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜