替换超链接

If I have a hyperlink that I format remove some elements then pass to a jquery dialog box as the title. When the box closes how can I reformat my hyperlink back to its original state? I have a ajax command that is fired when the link is clicked. So v, d, Hyperlink and a are all populated in the ajax and passed to openBox. The link itself contains subscripts which I do not want in my title bar. So I remove them and pass the new value to the title bar. With the code as it is now once the box closes the link is replaced with regular text and not a hyperlink as it originally was.

Here is my code:

    function openBox(v, d, HyperLink1, a) {

    //console.log(v);        
    var name1 = HyperLink1;
    name2 = $(a).find('sup').remove().end().html();

    $("#mapDiv").dialog({
        modal: false,
        autoOpen: false,
        height: 600,
        width: 900,            
        title: "Deomographic Profile - " + name2 ,
        close: function (ev, ui) {
            globals.map.destroy();
            //$(a).replaceWith(name);
            $(a).replaceWith(HyperLink1);
        }
    });

    //open dialog and show the legend in the dialog
    $("#mapDiv").dialog("open");
    $("#legend").show();
}//end open box

Clone it instead of using the original:

name2 = $(a).clone().find('sup').remove().end().html();