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.
$(\'
Try a slight different approach:
//set string and append it as object
var myHtmlString = '';
$('body').append(myHtmlString);
//as you noticed you can't just get it back
var myHtmlStringBack = $('#myFrame').html();
alert(myHtmlStringBack); // will be empty (a bug in jquery?) but...
//since an id was added to your iframe so you can retrieve its attributes back...
var width = $('#myFrame').attr('width');
var height = $('#myFrame').attr('height');
var src = $('#myFrame').attr('src');
var myReconstructedString = '';
alert(myReconstructedString);