Jquery remove html <a href=""> if href is empty

boxhedge
boxhedge used Ask the Experts™
on
Hi all another simple one I guess I'm just not getting right.

I need jquery to search for any <a href  and if href is empty remove the html <a href=""> </a> but leave anything inside the tag be it text or img

so

<a href="">Text Content</a>
or
<a href=""><img src="img.jpg" /></a>

would become:
Text Content
or
<img src="img.jpg" />

regards
Lee
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
for example : $("a[href='']").each(function() { $(this).replaceWith($(this).contents()); });

test page : http://fiddle.jshell.net/3RYWN/show/
code : http://jsfiddle.net/3RYWN/

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial