zorro76
@zorro76

Как с помощью each jquery перебрать неделю календаря и найти необходимые события?

Есть неделя календаря (структура формируется динамически) и необходимо пробежаться с помощью each и найти все event-item которые начинаются в одно время любого дня. Как это реализовать (нужна помощь, идея) Спасибо.

const events = $(this).find('.event-item');
let dataTimeStart = $(this).find('.cell').attr("data-time-start");

            if (dataTimeStart === dataTimeStart && events.length > 1) {
                console.log(events.length);
            }

<div class="days">
  <div class="day">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 00:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 01:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 02:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 03:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 04:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 05:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 06:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 07:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 08:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 09:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 10:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 11:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 12:00">
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 13:00">
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 13:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 14:00">
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
   </div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 15:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 16:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 17:00">
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
   </div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 18:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 19:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 20:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 21:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 22:00"></div>
   <div class="cell" data-date="2020-08-30" data-time-start="August 30, 2020 23:00"></div>
</div>
    <div class="day">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 00:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 01:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 02:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 03:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 04:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 05:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 06:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 07:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 08:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 09:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 10:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 11:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 12:00">
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 13:00">
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 13:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 14:00">
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
   </div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 15:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 16:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 17:00">
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
     <div class="event-item" style="border-color: #89D260; top: 0.0px; height: 100.0px; left: 0px; right: 0px"></div>
   </div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 18:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 19:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 20:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 21:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 22:00"></div>
   <div class="cell" data-date="2020-08-31" data-time-start="August 31, 2020 23:00"></div>
</div>
  <div class="day">.....</div>
  <div class="day">.....</div>
  <div class="day">.....</div>
  <div class="day">.....</div>
  <div class="day">.....</div>
</div>

https://jsfiddle.net/sergsagan/arb6zchn/66/
  • Вопрос задан
  • 82 просмотра
Пригласить эксперта
Ответы на вопрос 1
SpiderPigAndCat
@SpiderPigAndCat
занимаюсь салообразованием

ня кавай
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы