views:

36

answers:

2

hello, can someone help me with jquery. i have a html TAG like this

<p class="celak">hohohohoho</p>

and i want to make the output (give its parent) be like this

<div class="celak-parent"><p class="celak">hohohohoho</p></div>

is there somebody know which jquery method can do that?

$('.class').???

sorry if my write not very good. this first time i asking here.

+4  A: 

The wrap method is what you need. (http://api.jquery.com/wrap/)

$('.celak').wrap('<div class="cleak-parent"></div>');
IgalSt
Thank you bro, this is what i looking for..
GusDe CooL
You're welcome.
IgalSt
A: 

If your div does not exist at all you might use the wrap method:

$("p.celak").wrap("<div class='celak-parent'/>");

If your div does exist you can easily target and modify it with the parent method:

$("p.celak").parent().addClass('celak-parent');
Ghommey