Using jquery to modify a form's submit address basic ideas _jquery

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.