thanks MATT!

On Jun 19, 3:55 pm, Matt Kruse <m...@thekrusefamily.com> wrote:
> On Jun 19, 9:02 am, mojoeJohn <mojoej...@gmail.com> wrote:
>
> > obviously, i want thetexttotogglethe words "show" and "hide" in
> > accordance to the slidetoggle.
>
> I keep this in my toolbox:
>
> //Toggletextwithin an element using regular expressions.
> // Useful for changing "show" to "hide" and back when toggling element
> displays, for example
> jQuery.fn.toggleText = function(a,b) {
>         return this.html(this.html().replace(new RegExp("("+a+"|"+b
> +")"),function(x){return(x==a)?b:a;}));
>
> }
>
> Example:
>
> $('#mydiv').toggleText('show','hide');
>
> You can pass in regextext, and it cantoggletextwithin a string
> like:
>
> "Click here to show all items"
>
> and it will justtogglethe word "show" to "hide".
>
> Hope it's useful.
>
> Matt Kruse

Reply via email to