[jQuery] Re: jquery toggle class, I needed to switch class....

2009-04-12 Thread Ricardo
This is exactly the same as $(selector).toggleClass(a).toggleClass(b) On Mar 23, 2:47 pm, Eric Garside wrote: > Or: > > jQuery.fn.switchClass( a, b ){ >    var t = this.hasClass(a); >    this.addClass( t ? b : a ).removeClass( t ? a : b ); > > } > > On Mar 23, 12:35 pm, "T.J. Crowder" wrote: >

[jQuery] Re: jquery toggle class, I needed to switch class....

2009-04-12 Thread dongle
didnt you forget jQuery.fn.switchClass=function ??? On Mar 23, 7:47 pm, Eric Garside wrote: > Or: > > jQuery.fn.switchClass( a, b ){ >    var t = this.hasClass(a); >    this.addClass( t ? b : a ).removeClass( t ? a : b ); > > } > > On Mar 23, 12:35 pm, "T.J. Crowder" wrote: > > > Hi, > > > You'

[jQuery] Re: jquery toggle class, I needed to switch class....

2009-03-23 Thread Eric Garside
Or: jQuery.fn.switchClass( a, b ){ var t = this.hasClass(a); this.addClass( t ? b : a ).removeClass( t ? a : b ); } On Mar 23, 12:35 pm, "T.J. Crowder" wrote: > Hi, > > You're creating (or worse, overwriting) global variables 'remove' and > 'add' there (because you haven't given the 'var'

[jQuery] Re: jquery toggle class, I needed to switch class....

2009-03-23 Thread T.J. Crowder
Hi, You're creating (or worse, overwriting) global variables 'remove' and 'add' there (because you haven't given the 'var' keyword, and thus are creating implicit globals[1]). The temporaries don't really buy you anything anyway, perhaps simply: jQuery.fn.switchClass = function(class1,class2) {