Is it possible to combine this javascript function into JQuery?
<p>I have a function written in javascript and I'd like to know how, if it's possible, to use it in my JQuery file. I'm using the following function and my selector id is '#comments'.</p>

<p>Again, all I want to do is just consolidate this function which now resides in another file, into my main JQuery file. Is this possible?</p>

<pre><code>onkeydown="textCounter(this.form.notes, this.form.remLen,240); "onkeyup="textCounter(this.form.notes, this.form.remLen, 240);"
</code></pre>

<p>The selector id is #comments.</p>

<hr>

<pre><code>function textCounter( field, countfield, maxlimit ){
if ( field.value.length &gt; maxlimit )    {
    field.value = field.value.substring( 0, maxlimit );
}else{
    countfield.value = maxlimit - field.value.length;
}
</code></pre>
