Вход

Просмотр полной версии : Поиск и проверка элемента и удаление класса


Янковиц
17.10.2017, 10:26
Есть html разметка:
<table>
<thead>
<tr>
<td>Пн</td>
<td class="calendar note">Вт</td>
<td>Ср</td>
<td class="calendar note">Чт</td>
<td>Пт</td>
<td class="holiday">Сб</td>
<td class="holiday">Вс</td>
</tr>
</thead>
</table>
Размер таблицы будет неограничен. Расположение классов может быть вразброс.
Как найти все td с классом note и удалить в них класс calendar. Спасибо.
Я так понимаю нужно проверить все td в tabel.

Nexus
17.10.2017, 10:31
document.querySelector('td.note.calendar').classLi st.remove('calendar');

Янковиц
17.10.2017, 10:39
document.querySelector('td.note.calendar').classLi st.remove('calendar');

Спасибо. Но удаляет только у первого, нужно у всех.

Nexus
17.10.2017, 10:43
Янковиц,
document.querySelectorAll('td.note.calendar').forE ach(function(item){
item.classList.remove('calendar');
});

Янковиц
17.10.2017, 10:45
Спасибо, все работает :dance: :thanks:

рони
17.10.2017, 10:48
:write: на всякий случай forEach в ie c querySelectorAll не работет нужен call