html - Add content before and after a class - jQuery -


how add div starter "<div class='abc'>" <img src="bla.jpg" class="xyz"/> , end "</div>"
dom be:

<div class='abc'>    <img src="bla.jpg" class="xyz"/> </div>       

i tried using jquery code:

$('img.xyz').before("<div class='abc'>").after("</div>"); 

but gives me dom as:

<div class='abc'></div> <img src="bla.jpg" class="xyz"/> 

$('img.xyz').wrap('<div class="abc" />'); 

http://api.jquery.com/wrap


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -