I have images on my website, some have the target="_blank" attribute and some not.
here are 2 examples :
with target=_blank :
<a href="/mission.jpg" target="_blank"><img class="alignnone size-medium wp-image-1270" src="/mission-300x289.jpg" alt="mission" width="300" height="289" /></a>
without target=_blank :
<a href="/mission_1.jpg"><img class="alignnone size-medium wp-image-1271" src="/mission-300x289.jpg" alt="mission_1" width="300" height="289" /></a>
I'm using this code to remove the links from my images :
$("a:has(img)").each(function() { $(this).replaceWith($(this).children()); })
no I would like to add a condition to remove the link only if the image has not target=_blank attribute.
can anybody helpe me with this ?
thanks a lot for your help;
Try
OR
Fiddle