mrvinil
4/4/2017 - 2:03 PM

Вычисляем индекс элемента в блоке и присваиваем блоку нужный .class

Вычисляем индекс элемента в блоке и присваиваем блоку нужный .class

$(document).ready(function () {
    $(".has-drop__drop").each(function() {
      if ($(this).children("li").last().index() < 9) {
        $(this).addClass("has-drop__drop--1");
      } else if ($(this).children("li").last().index() < 19) { 
        $(this).addClass("has-drop__drop--2");
        } else {
        $(this).addClass("has-drop__drop--3");
        }
    });
});