Domanda

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top