$(".widget-content").each(function(i){
    console.log($(this).prev());//It prints the correct string that I want "<script id="meta..."
    // get div html
    var getthishtml = $(this).html();
    // empty this div html
    $(this).html();
    // move prev script inside div 
    $($(this).prev()).prependTo(widgetsHtml);
    // append div html
    $(this).append(getthishtml );
    // move next script inside div
    $($(this).next()).prependTo(widgetsHtml);   
});
DEMO you can check inspent elements to get the result