Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Created September 3, 2012 07:41
Show Gist options
  • Save devinrhode2/3607684 to your computer and use it in GitHub Desktop.
Save devinrhode2/3607684 to your computer and use it in GitHub Desktop.
Idea for class getter/setter hooks for jQuery

Introduction:

First, checkout Animate.css

Don't continue until you've checked it out. Go, go now.

Now, consider actually using this, you do: $('#button').addClass('pulse')

This css class uses modern css3 for all it's magic, but flat out won't work (to my knowledge) on older browsers.

To the rescue: a class getter/setter hook into jQuery.

What we need here is the ability to have some javascript hook when we do .addClass('pulse') and .removeClass('pulse')

The syntax for these getter/setters might look like this:

$.classHook('pulse').onAdd(function(){
  //if ie, perform fallback
});

$.classHook('pulse').onRemove(function(){
  //if ie, perform fallback
});

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment