Basic ideas:
By using the jquery selector to get the jquery object for the form, and then using the Attr method to modify the corresponding action
Sample program One:
By default, the form is submitted to the page_one.html
When you click the button, the form's submission address is modified to page_two.html
Copy Code code as follows:
<!doctype html>
<meta charset= "Utf-8" >
<title>jquery test</title>
<script src= "Jquery-1.11.1.min.js" ></script>
<body>
<div>
<form action= "page_one.html" id= "Qianshou" >
<input type= "Text"/>
<input type= "Submit" value= "submitted"/>
</form>
</div>
<div>
<button name= "Update" > Modify form's submit address is page_two.html</button>
</div>
</body>
<script>
var $fun = $ (' button[name=update] ');
$fun. Click (function () {
$ (' Form[id=qianshou] '). attr (' action ', ' page_two.html ');
});
</script>
Example program two:
The form's original action address is page_one.html, which is directly modified via jquery to page_two.html
Copy Code code as follows:
<!doctype html>
<meta charset= "Utf-8" >
<title>jquery test</title>
<script src= "Jquery-1.11.1.min.js" ></script>
<body>
<div>
<form action= "page_one.html" id= "Qianshou" >
<input type= "Text"/>
<input type= "Submit" value= "submitted"/>
</form>
</div>
</body>
<script>
$ (' Form[id=qianshou] '). attr (' action ', ' page_two.html ');
</script>