Thank you. I think it should work - I will give it a try tomorrow. The whole mess is just to store these html strings in the database and extract it later to render a part of the page.
any better solutions for this? On Feb 2, 9:20 pm, boermans <boerm...@gmail.com> wrote: > On Feb 2, 7:50 pm, Frederik Ring <frederik.r...@gmail.com> wrote: > > > So you could just either wrap it in a dummy-div or add the <div > > id="test"> and </div> code manually? > > Something like this should do the trick. > $('<div>').append($('#test').clone()).html(); > > Not sure if jQuery disposes of the new node and it’s cloned contents > afterwards. > If you are doing this a lot I suggest you assign your phantom div > container a variable and reuse it. > > var temp = $('<div>'); > var thishtml = temp.html($('#test').clone()).html(); > > But really this is a lot of messing around that may not be necessary > depending on what you want to do with thishtml.