Remove hyperlink from an image with jQuery

2

Is it possible to remove jQuery from this image? It may be simple, I even searched in English but I did not find the proper code or instruction.

<a href="sushione2p.jpg">
    <img class="alignright wp-image-69" src="sushione2p-250x166.jpg">
</a>

The expected result is:

<img class="alignright wp-image-69" src="sushione2p-250x166.jpg">
    
asked by anonymous 12.06.2014 / 05:02

1 answer

6

Yes, it is possible.

jQuery has a function called unwrap , which removes the parent from the element by leaving the element (child) in place of it.

In the specific case it would look like:

$('img').unwrap();

Of course you can customize it because of the selector.

JSFiddle of the code.

    
12.06.2014 / 05:05