[英]Why can't I submit my form?
我有一個模態彈出窗口,我想在單擊“陰影”時隱藏,但不是在單擊內容時隱藏。 為此,我有:
$('#shade').click(function(){
$('#shade').fadeOut();
}).children().click(function(e){
return false;
});
問題是我有一個我要提交的表單,這段代碼阻止表單提交,所以我有:
$('#shade-form-submit').click(function(){
document.getElementById('shade-form').submit();
});
但是,這會導致控制台中出現以下錯誤:
[13:07:21.145] TypeError: document.getElementById(...).submit is not a function @ ...
這是怎么回事? 作為參考,我的<form>
標簽:
<form action='.' method='post' id='shade-form'>
<div>
<input type='text' />
</div>
<div>
<div>
<input type='submit' />
</div>
</div>
</form>
您需要從children()
上的單擊處理程序中排除表單輸入:
$('#shade')
.click(function(){
$('#shade').fadeOut();
})
.children().not(':input').click(function(e){
return false;
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.