I would like to convert a html element created from a string back to the string after some modifications. But I get an empty string instead.
$(\'
What you want is the outer HTML, not the inner HTML :
$('')[0].outerHTML;