我有一個這樣的形式...jQuery的提交()函數不引起<form>提交
<form action="/tags/3" class="edit_tag" id="edit_tag_3" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="_method" type="hidden" value="put" />
</div>
<input class="tag_form_field" id="tag_name" maxlength="255" name="tag[name]" size="42" type="text" value="" />
</form>
而且我想提出像這樣......
$('.tag_form_field').change(function() {
$(event.target).closest('form').submit();
});
當我改變了輸入,表單不提交。沒有任何反應 - 沒有錯誤。
我知道選擇器和onChange()處理程序都工作。我用jQuery css()
函數替換submit()
來測試它們,它工作正常。
我在OS X上的Safari和Chrome中測試了它,結果相同。
任何想法?
謝謝。
我同樣的結果嘗試這些以及...
$('.tag_form_field').change(function() {
$(this).closest('form').submit();
});
$('.tag_form_field').change(function(e) {
$(e.target).closest('form').submit();
});
$('.tag_form_field').change(function() {
$(this).closest('form').submit();
});
$('.tag_form_field').change(function() {
$(this).closest('form')[0].submit();
});
謝謝。但我想在表單上觸發提交事件。這是目標。你能澄清嗎? – Ethan 2011-04-24 22:12:37
我的代碼實際上提交了表單。 – ThiefMaster 2011-04-24 22:18:08