DISABLE ADBLOCK

ADBlock is blocking some content on the site

ADBlock errore

Question

I have this html

<div class="pic">
     <a class="shutterset_publication-workshop" title="" href="http://localhost/639.jpg">
    <img src="http://localhost/researchclub/yu.jpg" alt="copy-of-dsc03639">
     </a>
</div>

The problem is that i want to replace the 'href' attribute of the anchor tag using jquery while preserving the img element using jquery, but have failed.

$(".pic a['href']").replaceWith("<a>") is not working.

No correct solution

OTHER TIPS

Use the attr function to do this. There is no need to replace the element when you can modify it.

$(".pic a['href']").attr('href', 'http://google.com');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow