Have you tried toggleClass?: http://docs.jquery.com/Attributes/toggleClass
- Richard On Tue, Jul 15, 2008 at 8:30 PM, jquertil <[EMAIL PROTECTED]> wrote: > > $("p").hover(function(){ > $(this).addClass("hover"); > },function(){ > $(this).removeClass("hover"); > }); > > this is kind of a verbose way of swapping classes, isn't it? > > I imagine it would not add much to the lightweightness of jquery if it > allowed something like: > > $("p").hoverSwap("hover"); > > or, if more versatility is desired, perhaps something like: > > $("p").swapClass("hover", "click"); // hover is class name and click > is the event name > > I can use my own extension I suppose, but then again, swapping classes > on hover and click seems like such an often-used functionality it > might just warrant inclusion into the library... > > > just an idea... >