最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery .submit method - Stack Overflow

programmeradmin1浏览0评论

I am using Jconfirm together with jQuery to make a confirmation box.
The problem is that the .submit does not work

Javascript

$('#delete').submit(function(e) {
e.preventDefault();
jConfirm("Are you sure you want to delete this link?", "Confirmation", function(r) {  
if (r) { $('#delete').submit(); }
});

The $('#delete').submit(); seems to be dead.

HTML

<form action="bla.php" method="post" accept-charset="utf-8" id="delete">
 <table>
<tr>
<td><label for="category">Category:</label></td><td><select name="category_id"           id="categories">
<option value="1">test</option>
<option value="#" selected="selected">Please select</option>
</select></td>
</tr>
<tr>
<td><label for="links">Link:</label></td><td width="400"><select name="link_id" id="links">
<option value="#" selected="selected">Please select</option>
</select></td>
</tr>
<tr>
<td></td><td><input type="submit" value="Delete" ></td>
</tr>
</table>
</form>

I am using Jconfirm together with jQuery to make a confirmation box.
The problem is that the .submit does not work

Javascript

$('#delete').submit(function(e) {
e.preventDefault();
jConfirm("Are you sure you want to delete this link?", "Confirmation", function(r) {  
if (r) { $('#delete').submit(); }
});

The $('#delete').submit(); seems to be dead.

HTML

<form action="bla.php" method="post" accept-charset="utf-8" id="delete">
 <table>
<tr>
<td><label for="category">Category:</label></td><td><select name="category_id"           id="categories">
<option value="1">test</option>
<option value="#" selected="selected">Please select</option>
</select></td>
</tr>
<tr>
<td><label for="links">Link:</label></td><td width="400"><select name="link_id" id="links">
<option value="#" selected="selected">Please select</option>
</select></td>
</tr>
<tr>
<td></td><td><input type="submit" value="Delete" ></td>
</tr>
</table>
</form>
Share Improve this question edited Aug 9, 2022 at 8:36 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked May 15, 2012 at 8:32 HyperDevilHyperDevil 2,6499 gold badges42 silver badges52 bronze badges 1
  • And by "not work" you mean what exactly? – Jan Hančič Commented May 15, 2012 at 8:32
Add a ment  | 

1 Answer 1

Reset to default 10

try to change

if (r) { $('#delete').submit(); }

with

if (r) { $('#delete').get(0).submit(); }

so you call the submit() method available for the DOM element

发布评论

评论列表(0)

  1. 暂无评论