Function passed as parameter, has own parameters that are not defined, still have values
<p>I am using a slightly modified version of a converting a keyword to a link presented in another question here.</p>

<p>The code, with some omissions, is as following:   </p>

<pre><code>$(".keyword_search").each(function() {
    var targetword = 'TEST';
    var explanation = 'Is something you do to find out if stuff works';
    //targetword and explanation actually defined in a loop, but omitted here  
    var content = $(this)[0];
    var re = new RegExp("(\\b"+targetword+"\\b)", "gi");
    content.innerHTML = content.innerHTML.replace(re,keywordconvert);
}

function keywordconvert(str, p1, offset, s ) {
     return '&lt;a href="#" data-toggle="tooltip" title="'+p1+'"&gt;'+p1+'&lt;/a&gt;';
}
</code></pre>

<p>I have few questions about this code.</p>

<p>1) Where are the parameters of <strong>keywordconvert</strong> defined? <em>str</em> and <em>p1</em> both contain the string to be replaced, <em>offset</em> contains the starting point of the word in the the content and <em>s</em> contains <em>content</em>.</p>

<p>2) How would I go about adding the explanation string to the <em>title</em>-class of the the link in the <strong>keywordconvert</strong> function? In other words, how can I add parameters to this function?</p>

<p>Any help would be appreciated, I've been scouring the web for answers for far too long.</p>
