R
R
Roman Makarov2015-10-12 18:29:24
JavaScript
Roman Makarov, 2015-10-12 18:29:24

How to filter out some of the elements selected by the class selector?

For example, there are a number of blocks with the class .class, for these blocks, under certain conditions, $('.class').slideUp();

Is it possible to prevent the execution of a command on some elements of this class by any means of jquery / underscrore, for example, so that the block with the class .class and id .id does not collapse?

Only one solution comes to my mind - to collect the NodeList, convert it to an array and use _.each() to weed out unnecessary ones, but this requires its own implementation of slideUp(), and as a result, shit code noodles are obtained.

Or you need to somehow change the object returned by jquery, but it has a very confusing structure.
Maybe I'm trying to reinvent the wheel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-10-12
@rmakarov

$(".class").not("#id").slideUp();
There are also filters and non-standard selectors for more complex situations:

$(".class").filter(function(){
    return this.value == this.offsetHeight;
}).slideUp();

$(".class:hidden").slideUp();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question