What is the best way of "overriding" the .toggle() function of jquery?
<p>I want to change the toggle function so that it changes the text of the link to say "show/hide" or "expand/collapse".</p>

<p>The function definition and call in classic JS would be:</p>

<pre><code>function myToggle(expandText, collapseText, id,o){
   // expandText: "expand", "show", "display"
   // collapseText: "collapse", "hide"
   // id: the id of the div to toggle
   // o: the object from where the function has been called
}
</code></pre>

<p>I would then call it as such:</p>

<pre><code>&lt;a href="#" onclick="myToggle('Show','Hide', 'myId', this); return false;"&gt;Show the div&lt;/a&gt;
&lt;div id='myId'&gt;Hi!&lt;/div&gt;
</code></pre>

<p>It would do a replacement of the "Show" string by "Hide" and show() the div. Clicking again will reverse back to the previous state. Pretty simple stuff, that is not the problem.</p>

<p><hr /></p>

<p>I'm new to jquery but I already love it. I know there is a clean way of creating something like this but I'm not sure how to use it...</p>

<p>So the question is: <strong>How would you define and call such a function? What's the best and cleanest way of doing so (should I change jquery's toggle, create my own...) ?</strong></p>

<p>Any pointers or reading up (no books please, I still need to get that done today :) ) will be appreciated. You do not need to actually write the function body to get accepted.</p>
