<form id='new_key' action='/foo/bar' method='post'>
<input type="text" id="u">
<input type="submit" value="submit">
</form>
I can bind a jQuery event to this element like:
$('#new_key').ready(function () {
alert('Handler for .submit() called.');
return false;
});
It works as expected, but if I do:
$('#new_key').submit(function () {
alert('Handler for .submit() called.');
return false;
});
it doesn’t work. Does anybody know why? What am I missing?
Try wrapping your code in a
$(function() { })block: