jquery remove of prepended element not working
<p>Basically, I want to have two functions. The first prepends an element <code>div</code> which contains some ajax data and a button which can fire the close function. The first function does everything I want it to, except I'm having trouble applyin the <code>onclick</code> attribute on the  which will fire the remove function when clicked.</p>

<p>But independent of this, I haven't been able to get the <code>remove function</code> to work. </p>

<p>If you can help me do this better I would be grateful.</p>

<pre><code>function displayCrRef(refPid, refFs, pidOfReferringP) {

    $.get("crRefParaExtract.php", {
        pid: refPid,
        fs: refFs
    }, function(data) {

        $("#pwrap_" + pidOfReferringP).prepend("&lt;div id='#crRef_" + refPid + "' style='float: left;  width: 350px; margin-right: 60px; padding: 10px; background-color: #E6EDE8'&gt;" + "&lt;a id='crossRefRemoveButton'&gt;Return to normal text&lt;/a&gt;" + data + "&lt;/div&gt;");


    });
    var rmFxnParam = "'" + refPid + "'";
    $("#crossRefRemoveButton").attr("onclick", "removeCrossRef(" + rmFxnParam + ")");
    $("#" + pidOfReferringP).css({
        float: 'left',
        width: '425px'
    });
    $("#menu_" + pidOfReferringP).css({
        float: 'none',
        clear: 'both'
    });
   }


   function removeCrossRef(refPid) {
       $("#crRef_" + refPid).remove();

   }​
</code></pre>
