TypeError:document.getElementById(...).submit不是一个函数 [英] TypeError: document.getElementById(...).submit is not a function

查看:70
本文介绍了TypeError:document.getElementById(...).submit不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个错误,找不到解决方案,也不必使用jQuery.我没有任何以名称提交的div

I'm having an error that I can't find the solution and I don't have to use jQuery; I don't have any div with submit as name

我的代码是

<!DOCTYPE html>    
<html>    
<head>    
<script>    
function formSubmit()    
{    
     document.getElementById('web').submit();    
}    
</script>    
</head>    
<body>    
<form action="class003.php" id="g_form" method="POST">    
<input type="text" name="f1" value="">    
</form>    
<div id="web" onclick="formSubmit()">click</div>    
</body>    
</html>

在chrom上出现此错误

on chrom I'm getting this error

未捕获的TypeError:document.querySelector(...).submit不是功能在formSubmit(test2.html:8)在HTMLDivElement.onclick(test2.html:19)

Uncaught TypeError: document.querySelector(...).submit is not a function at formSubmit (test2.html:8) at HTMLDivElement.onclick (test2.html:19)

在Firefox上出现相同的错误

on Firefox the same error

TypeError:document.getElementById(...).submit不是一个函数[学习更多]

TypeError: document.getElementById(...).submit is not a function[Learn More]

推荐答案

您需要提交 form 而不是 div

制作

document.getElementById('g_form').submit();    

这篇关于TypeError:document.getElementById(...).submit不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆