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 () {
精彩评论