I'm using Gravity form on my Wordpress site, Gravity form generate automatic form action, I was wondering if i can add a query at the end of each action.

This is default code which is generated

<form method='post' enctype='multipart/form-data'  id='gform_4'  action='/free-trial/'>

And i want to be like

<form method='post' enctype='multipart/form-data'  id='gform_4'  action='/free-trial/#testdiv'>

I searched and found lots of jquery or php code which was over my head, i just need a simple code.

Any help would be appreciated

有帮助吗?

解决方案

You could try getting the current form action value first, append the desired hash query then set the new value to the action attribute:

var url = $('#gform_4').attr('action') + '#testdiv';
$('form').get(0).setAttribute('action', url); 

JSFiddle

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top