Rich-text Reply

Adding a hyperlink to an image with predefined class

mspradlin 02-02-16

Adding a hyperlink to an image with predefined class

I have a homepage image that is defined as a Div and is supposed to have text over it that links somewhere. However I want to remove the text, upload and image with a "register now" button already on it and have the entire image link to a certain page. I have tried placing the href link in the html but it isn't clickable in the live preview. Any way to look at this code and tell me where to place to hyperlink?

 

<div class="headline mini-headline" style="background-image: url(&quot;//cdn.optimizely.com/img/3365092136/4e632f5c8c98466e8ff4f9478cffb852.jpg&quotSmiley Wink;">
<div class="headline-box" style="visibility: hidden;">
<h1 class="headline-title" style="visibility: hidden;">
<a style="visibility: hidden;">
One Weekend Could Change Your Marriage
</a>
</h1>
<div class="date">

</div><!-- date -->
</div>
</div>

robertchan 02-03-16
 

Re: Adding a hyperlink to an image with predefined class

Place this in your variation code.

//removes the text and link
$(".headline").remove();

//create your new element
var optEl = [
'<a href="yourURL">',
'<img src="yourUploadedImageURL">',
'</a>'
].join('');

//append the element to the body of your page
$(optEl).appendTo("body");

//from this point, you can move the new element around as you please.
Robert Chan

Experimentation Hero