gpt4 book ai didi

jquery - $ ("#MyForm").submit(function () { 在 IE8 中不起作用,但在 FireFox 8 中不起作用?

转载 作者:行者123 更新时间:2023-11-30 23:43:38 24 4
gpt4 key购买 nike

$(document).ready(function () {
$("#MyForm").submit(function () {
alert("Hello");
return true;
});
});

嗨,我上面有一个非常简单的代码,当我在 IE8 中提交表单时没有任何反应,但它在 FireFox 8 中工作正常。

我使用的是 jQuery 1.5.1。那么这是旧版本 jQuery 的问题吗?

最佳答案

我以前在 IE8 和 IE7 中见过这个。解决方法:

$("#MyForm").submit(function () {
alert("Hello");
return true;
});

// change input type to whatever submits the form
$("#MyForm input[type='submit']").click(function(e) {
e.preventDefault();
$(this).closest("form").submit();
});

关于jquery - $ ("#MyForm").submit(function () { 在 IE8 中不起作用,但在 FireFox 8 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8386659/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com