0

I have no idea where to start with this so I was hoping someone might be able to suggest a solution.

How do I extract the contents of the href tag of "product_prev" (/images/New-Image.jpg) and use it to replace the href tag of "product" (/images/Old-Image.jpg)

Here is my HTML...

<a class="product_prev" href="/images/New-Image.jpg"><img alt="" title="" src="/images/New-Image.thumb.jpg" width="50"></a>

<a class="product" href="/images/Old-Image.jpg"><img class="displayer ct_pd_pi_mainImage ct_pd_pi_fullsizeImage" alt="" title="Venicci-Mini-Pram-Black" itemprop="image" src="/images/Old-Image.jpg"></a>

I'm unable to edit the template of the site but I can add CSS/Javascript/JQuery so hopefully a solution using these methods can be used.

Thanks in advance.

2 Answers 2

2

You can use attribute selector of jquery to get and set the href

$(".product").attr("href",$("product_prev").attr("href"));
Sign up to request clarification or add additional context in comments.

Comments

0

This can be easily done with jQuery.

var first_href= $(".product_prev").attr('href');
$(".product").attr('href', first_href);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.