How to pass parameters permanently javascript function
<p>How would I make this function work so that whenever the element I created is clicked it uses the parameters from the function in the actual click event.</p>

<pre><code> function createLink(text, parentElement) {
        var a = document.createElement('p');
        var linkText = document.createTextNode(text);
        a.appendChild(linkText);
        temp1 = text.replace("/","-");
        temp2 = res1.replace("/","-");
        a.onClick = goSpecificPrev(temp2,linkText);
        parentElement.appendChild(a);
        var br = document.createElement('br');
        parentElement.appendChild(br);
    }
</code></pre>

<p>The parameters in questions are in the line:</p>

<pre><code>a.onClick = goSpecificPrev(temp2,linkText);
</code></pre>

<p>being temp2 and linkText.</p>