Reputation: 778
although I have been coding jQuery for quite some time now, I was just wondering, what is the difference between $("#test").submit();
and $("#test).submit(function(e){...});
functions?
The example here doesn't seem to be very clear to me...
Can anyone give any example to show a great use for both of them?
Upvotes: 0
Views: 158
Reputation: 10254
$("#test").submit()
This will trigger a submit to #test, if this is a .
$("#test").submit(function(e) { } )
This will bind a handler function for submit event at form #test.
You can use 1st to submit a form without user interference, for example.
And you can use 2nd to bind a handler function that do something before form submitting, or event disable form submitting by using e.preventDefault().
Upvotes: 1