A
A
ABdominal2019-03-09 23:43:52
css
ABdominal, 2019-03-09 23:43:52

How to select all elements up to class(CSS)?

It has the following structure:

<li>1</li>
<li>1</li>
<li>1</li>
....
....
<li class="class">2</li>
<li>2</li>
<li>2</li>


How to select all elements up to class "class". Those. everything above this class, with a conditional value of 1
Only css and jquery selectors are available

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2019-03-09
@ABdominal

$( "li.class" ).prevAll()
UPD:
li:not(.class, .class ~ li)

V
Vitaly Kirenkov, 2019-03-09
@DeLaVega

Substitute the method you need, I just added a class

$('li.class', 'ul').prevAll().addClass('prev-item');

K
KononovD, 2019-03-10
@KononovD

set those items that are needed - a separate class and not reinvent the wheel)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question