最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Button click event not firing in jQuery - Stack Overflow

programmeradmin1浏览0评论

This is the method:

$(document).ready(function () {
    $('btnDelete1').click(function () {
        alert("something");
    })
});

And this is the code for the button:

<input type="submit" value="Delete Role" disabled="disabled" id="btnDelete1"/>

But whenever I click the button, the alert isn't happening. Why is this?

This is the method:

$(document).ready(function () {
    $('btnDelete1').click(function () {
        alert("something");
    })
});

And this is the code for the button:

<input type="submit" value="Delete Role" disabled="disabled" id="btnDelete1"/>

But whenever I click the button, the alert isn't happening. Why is this?

Share Improve this question edited Jan 16, 2012 at 13:26 Chuck Norris 15.2k15 gold badges95 silver badges127 bronze badges asked Jan 16, 2012 at 13:01 dfgj fghjkdfgj fghjk 411 gold badge2 silver badges7 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

The problem isn't connected with MVC anyway, you missed # in Jquery selector only.

$(document).ready(function () {
    $('#btnDelete1').click(function () {
        alert("something");
    });
});

EDIT:

And as mentioned Jeffrey, you forget ; too

Your selector is wrong

It should be

$(document).ready(function () {
    $('#btnDelete1').click(function () {
        alert("something");
    });
});

Did you forget a ;?

$(document).ready(function () {
    $('#btnDelete1').click(function () {
        alert("something");
    });
});
发布评论

评论列表(0)

  1. 暂无评论