开发者

How to prevent form on submit behavior in jquery?

I need to get an .click() event and prevent form from behaving as it was initially designed and make my own changes and submit. How is it possible?

EDIT: Form input actually has an onclick defined behavior. I need to redefine it somehow.

EDIT: Some code

<form action='link' method='get'>
   <input type="image" name=开发者_如何学编程"name" id="id" class="class" onclick="this.form.action='some_link'" title="Title" value="" src="image.gif">
</form>


If you don't want it to submit the form, return false at the end of your click function. If you want to submit the form, use the form element and call the submit function on it:

$('#myFormID').submit();


$('#form').submit(function(e) {
    // Some code
});

I think it's enough.


You could use something like this (haven't tested it but it should work)

form = $("#yourform");
button = $("#yoursubmit");
button.click(function(){
             dosomething();
             form.submit();
             return false;});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜