d
Amit DhamuSoftware Engineer
 

Wrap Element Around Other Element

1 minute read 00000 views

Take an image

<img src="image.jpg" alt="" />

We want to wrap a link around it using jQuery

$('img').wrap('<a href="http://www.google.co.uk"/>')

Which will result in

<a href="http://www.google.co.uk"/>
    <img src='image.jpg' alt=''/>
</a>