Yes, But the question was from an array of controls:
http://mootools.net/shell/hv3Yv/
Array.implement({
removeClassesExcept: function(klass) {
this.map(function(ele, ndx) {
return ele.hasClass(klass) ? ele.set("class", klass) :
ele.erase("class");
});
}
});
On Feb 14, 6:09 pm, Roman Land <[email protected]> wrote:
> (mooshell is down)
>
> how about this over engineered solution:
>
> var leaveOnlyThisClass = function(el, cl){
> el.set('class', el.get('class').split(' ').filter(function(c){return c
> == this },cl)[0]);
>
> };
>
> usage:
> leaveOnlyThisClass($('divid'),'leave-only-me');
>
> On Mon, Feb 15, 2010 at 12:32 AM, Dimitar Christoff
> <[email protected]>wrote:
>
>
>
> > > Anyway, this way is just a function around the same basic logic... not
> > > really reaching the "cleverer" mark. :)
>
> > the 'clever' i could think of without involving garden gnomes was this:
>
> > Element.implement({
> > removeClassesExcept: function(klass) {
> > return this.hasClass(klass) ? this.set("class", klass) :
> > this.erase("class");
> > }
> > });
>
> >http://mootools.net/shell/Wpqum/1/- tested in FF 2.5 and IE7. back to
> > gardening now...
>
> > regards,
> > --
> > Dimitar Christoff <[email protected]> -http://fragged.org/
>
> --
> ---
> "Make everything as simple as possible, but not simpler."
>
> - Albert Einstein