A
A
Art. Ku.2015-11-20 12:26:13
JavaScript
Art. Ku., 2015-11-20 12:26:13

How to correctly write a condition in jQuery?

Hello. Here, for example, how to find out that on page 10 they <li>go in a row and so as not to fence this:

if ($('li').next('li').next('li').next('li').next('li').next('li').next('li').next('li').next('li').next('li').css("display")=="block")


Those. how to simplify this expression? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
De YURII, 2015-11-20
@kukaew

https://api.jquery.com/last-child-selector/
:last-child switch to the last child immediately.

if($( "ul li:last-child" ).css('display') == 'block')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question