Using jquery to modify the submission address of the form


Basic ideas:

Get the jquery object for the corresponding form by using the jquery selector, and then modify the corresponding action using the attr method

Sample program 1:

By default, the form is submitted to page_one.html

When you click on the button, the submission address of the form is changed to page_two-html


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery test</title>
<script src="jquery-1.11.1.min.js"></script>
</head>

<body>
<div>
<form action="page_one.html" id="qianshou">
<input type="text"/>
<input type="submit" value=" mention   Hand in "/>
</form>
</div>
<div>
<button name="update"> Modify the form The submission 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>
</html>

Sample program 2:

The original action address of the form is page_one.html, which is directly changed to page_two-html through jquery


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery test</title>
<script src="jquery-1.11.1.min.js"></script>
</head>

<body>
<div>
<form action="page_one.html" id="qianshou">
<input type="text"/>
<input type="submit" value=" mention   Hand in "/>
</form>
</div>
</body>
<script>
$('form[id=qianshou]').attr('action','page_two.html');
</script>
</html>