When using jQuery, you can set it as follows:
form form:
<form name="myform" id="myform" action="ssss" method="post" onsubmit="getUrl();">
JavaScript method:
<script type="text/javascript"> function getUrl(){ $('form').attr('action','new_url'); } </script>Or use simple javascript:
function test1(){ alert(document.myform.action);//Return value: http://localhost:8080/XXX/ssss alert(document.myform.attributes["action"].value);//Return value: ssss is different from the previous line// In the following three lines, any line can be document.getElementById('myform').action='new_url'; document.myform.action='new_url'; document.myform.attributes["action"].value = 'new_url';}The above simple way to dynamically set the value of the action attribute of the form form is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.