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.