我想更改单击时提交表单的 URL,如下所示。以下是我尝试过的,但它不起作用。
<form action="" method="post" class="form-horizontal" id="contactsForm" enctype="multipart/form-data">
<div class="widget-content">
<div class="btn-group">
<button data-toggle="dropdown" class="btn dropdown-toggle">
<span class="icon-folder-open icon-large"></span>
Move To <span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% for x,y in actionsForm.fields.move_to.choices %}
<li><a class="move_to" id="{{ x }}" href="#">{{ y }}</a></li>
{% endfor %}
<script>
$(document).ready(function() {
$(".move_to").on("click", function () {
$('#contactsFrom').attr('action', "/test1");
$("#contactsFrom").submit();
e.preventDefault();
});
});
</script>