jQuery change URL of form submit

The Solution to jQuery change URL of form submit is

Try using this:

$(".move_to").on("click", function(e){
    $('#contactsForm').attr('action', "/test1").submit();

Moving the order in which you use .preventDefault() might fix your issue. You also didn't use function(e) so e.preventDefault(); wasn't working.

Here it is working: http://jsfiddle.net/TfTwe/1/ - first of all, click the 'Check action attribute.' link. You'll get an alert saying undefined. Then click 'Set action attribute.' and click 'Check action attribute.' again. You'll see that the form's action attribute has been correctly set to /test1.

~ Answered on 2013-06-06 15:43:24

Most Viewed Questions: