T
T
timtimIT2015-10-26 14:25:05
JavaScript
timtimIT, 2015-10-26 14:25:05

How, when hovering over li, the current li and all li that come before it, add the active class?

Hello.

Here's an example

How can I add the active class to the current li and all li that come before it when hovering over li?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bears, 2015-10-26
@timtimIT

So? jsfiddle.net/dae4mv0d

M
Maxim Timofeev, 2015-10-26
@webinar

As an additional option:
number the list, for example through data-num="1", cling to the hover event, get the number $(this).data('num'), run a for loop, add classes addClass('active')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question