Widget:Toc: различия между версиями
Материал из Ролевой сервер "tales.pw"
Xunto (обсуждение | вклад) |
Xunto (обсуждение | вклад) |
||
| Строка 13: | Строка 13: | ||
document.body.appendChild(element); | document.body.appendChild(element); | ||
| + | |||
| + | var headingSelector = "h1, h2, h3"; | ||
| + | |||
| + | $(headingSelector).each(function() { | ||
| + | var current_id = $(this).attr('id'); | ||
| + | console.log(current_id) | ||
| + | } | ||
| + | ); | ||
tocbot.init({ | tocbot.init({ | ||
tocSelector: '#tocbot', | tocSelector: '#tocbot', | ||
contentSelector: '#content', | contentSelector: '#content', | ||
| − | headingSelector: | + | headingSelector: headingSelector, |
hasInnerContainers: true, | hasInnerContainers: true, | ||
}); | }); | ||
</script> | </script> | ||
Версия 19:54, 30 ноября 2019
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.css">
<script>
var element = document.createElement("div"); element.id="tocbot" element.style["position"] = "fixed"; element.style["top"] = "55px"; element.style["left"] = "0px"; element.style["width"] = "200px"; element.style["height"] = "100%";
document.body.appendChild(element);
var headingSelector = "h1, h2, h3";
$(headingSelector).each(function() { var current_id = $(this).attr('id'); console.log(current_id)
}
);
tocbot.init({
tocSelector: '#tocbot', contentSelector: '#content', headingSelector: headingSelector, hasInnerContainers: true,
}); </script>