Does mootools provide the ability to fade () all but one element?

Mootools can preempt all nodes matching the selector as follows:

$$('#div img').fade(0.3);

I need to skip a specific node. In the jQuery world, I would use not (), and it would be something like this:

$$('#div img').not( oneElement ).fade(0.3);

But I cannot find a way to show similar behavior in mootools. Does anyone know anything?

+3
source share
2 answers

$$('#div img').erase(oneElement).fade(0.3);

http://www.jsfiddle.net/timwienk/Z9MNe/2/

+6
source

using .filter in a collection of html elements will have the same effect, provided that oneElement is a suitable object:

$$("img").filter(function(el) {
    return el !== oneElement;
}).fade(.3);

, mootools, , :

Array.implement({
    not: function(skipEl) {
        return skipEl ? this.filter(function(el) {
            return el !== skipEl;
        }) : this;
    }
});

var divs = document.getElements("div");
var redDiv = document.getElement("div.red");

divs.not(redDiv).fade(.2);

. : http://www.jsfiddle.net/dimitar/Z9MNe/

:

<div ></div>
<div ></div>
<div ></div>
<div class="red" ></div>
<div ></div>

FunFactor irc, , , :

$$('div.something:not(#someId)') , , this onClick.

+5

Source: https://habr.com/ru/post/1769078/


All Articles