On Jun 19, 9:02 am, mojoeJohn <mojoej...@gmail.com> wrote: > obviously, i want the text to toggle the words "show" and "hide" in > accordance to the slide toggle.
I keep this in my toolbox: // Toggle text within 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 regex text, and it can toggle text within a string like: "Click here to show all items" and it will just toggle the word "show" to "hide". Hope it's useful. Matt Kruse