开发者

JQuery onclick doing nothing

So here is my button:

<div id="calculateButton" style="cursor: pointer;">
    <img src="<%= VirtualPathUtility.ToAbsolute("~/img/chic/btn_calculate.gif")%>" />
</div>

And here is the javascript:

$('#calculateButton').click(function () {
    alert('Calculating...');
});

When I click the button nothing happens. What am I doing wrong?

Edits:

$(document).ready(function () {

        $("#prepaymentTable").bubble({ width: 400, title: 'Prepayment' });
        $("#exposureTable").bubble({ width: 400, title: 'Exposure' });

        $('#calculateButton').click(function () {
            alert('Calculating...');
        });

    });
开发者_如何学Python

The bubble plugins both work...but not the button click...


Make sure you're attaching the click handler inside a document.ready handler, after the element has loaded, like this:

$(function() {
  $('#calculateButton').click(function () {
    alert('Calculating...');
  });
});

If it's created later as the result of AJAX, etc, use .live(), for example:

$('#calculateButton').live('click', function () {
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜