开发者

jQuery: Weirdest issue with submitting a form with jquery?

I've been stuck with this issue for almost 3 days!

I have an input button: <input type="button" id="submit" value="Upload"/> Using jQuery 1.6.1, in the document.ready, I'm binding the button to submit the form like this:

$('#submit'开发者_开发问答).click(function() {
     $('form').submit();
});

Using FireBug, the line $('form').submit(); causes an error with jquery! After 3 days of trying to figure out the issue, it seems that naming the input button id="submit" is what's causing the bug! When I changed the id to something else, it worked!

Any technical explanation to this?


jQuery form submit() is not working in IE6?


This has something to do with the browser. The browser see the input as an submit button when defining an Id with submit. simply use this code will solve the problem:

$('#submit').click(function() {
     $('form').submit();
     return false;
}); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜