Rich-text Reply

Change all href="url1" values to href="url2"

Konstantin 09-17-15

Change all href="url1" values to href="url2"

Hi,

is there any way to change all href="url1" values to href="url2" .

This is to send people to different checkout pages sitewide.

Thanks in advance.

AllisonR 09-17-15
 

Re: Change all href="url1" values to href="url2"

Hi Konstantin,

 

This can be done using a CSS attribute selector in your variation code. In general, selecting the href attribute of a link will look like this:

 

$("a[href='url1']")

This will select all the links whose destination is url1. You can then use the .attr jQuery method to change this value to the new URL. So the final line of variation code will look like this:

 

$("a[href='url1']").attr("href", "url2");

Is this what you're looking for? Hope this helps! 

 

Allison
Sr. Technical Support Engineer
Optimizely | EMEA
Optimizely