I have a form like this:
<form class="category_form" id="category_form" method="post">
<p class="ui-widget">
<label for="birds">Birds: </label>
<input id="birds" /> <a id="add_category" href="#">Add Category</a>
</p>
<p class="ui-widget" style="margin-top:2em; font-family:Arial">
Result:
<textarea id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></textarea>
</p>
<p>
<input type="submit" class="button" value="Add">
</p>
</form>
and I have a jQuery bind function like this:
$('#category_form').bind('submit',function()
{
// Get the variables
alert ("hello");
return false;
});
What I wanted to have happen is every time submit button is pressed, the jQuery function would fire and the alert would happen, but for some reason it isn't working as I thought it would.
The live example is on this test page: http://problemio.com/test.php
Any idea why pressing the add button does not make the above jQuery work?
Thanks!!
your binding should be wrapped in $(document).ready
or it attempts to bind the form before the form exists on the page:
$(document).ready(function(){
$('#category_form').bind('submit',function(){
...
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With