views:

80

answers:

1

Hi Guys,

I'm parsing an xml file and I want to wrap children divs into a div called "new":

I have something similar to below:

function parseXml(xml)
{
 $(xml).find("hotel").each(function()
 {
 $('<div class="wrapme"></div>').html($(this).find("hotel_name").text()).appendTo('#foo');
 });
}
$('.wrapme').wrapAll('<div class="group" />');

// output: not working, it doesn't enclose my wrapme divs into Group

Anyone knows the reason ?

Appreciate your help guys!!

The problem is that .wrapAll doesn't seem to work in this particular cases

+1  A: 

The call to wrapAll is outside the function, so that will only run once when the javascript file is loaded. Is that what you meant to do?

Also, I'm not sure that wrapAll accepts self-closing elements like that. You might need to use <div></div>.

Stefan Kendall