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:
>
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'
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'
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) {
4 matches
Mail list logo