Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Ignore first H2?

Дата публикации: 21-10-2026 17:05:43

Two easy ways. If the ToC heading is always the first H2 on the page, just drop it from the array:
var headings = [].slice.call(documentRef.body.querySelectorAll('h2')).slice(1);
A sturdier option is to skip any H2 that sits inside the ToC container itself, so it keeps working even if the page order changes:
var headings = [].slice.call(documentRef.body.querySelectorAll('h2')).filter(function (h) {
return !toc.contains(h);
});
Use one or the other. If the ToC heading isn’t inside #toc, give it a class (for example class=“toc-title”) and use querySelectorAll(‘h2:not(.toc-title)’) instead.

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Accessibility regression after update — <ul class="x-menu"> has role="navigation" causing Lighthouse list errors010.7518-09-2026
2hiddenswitch - 404: page not found035.119-10-2026
3Class specific to cornerstone editor06.6218-09-2026
4highlight - 404: page not found034.819-10-2026
5Image Widget overlay caption stays visible on hover in stretched row06.3207-10-2026
6youtracklinks - 404: page not found034.7419-10-2026
7HTML и CSS из прошлого, которые до сих пор актуальны06.2413-10-2026
8playground030.0420-10-2026
9sequencediagram - 404: page not found035.6519-10-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 9. Тональность: 0. Информативность: 8.55. Источник: www.sitepoint.com.