带有更改文本的固定位置[关闭]

我有一段带有标题的文字。当文本向下滚动时,我需要在网页侧面的固定位置另外显示部分标题。固定位置是通过

<pf class="pos_fixed">
<div class="div1"><CHANGING TEXT></div>
</pf>

How is the <CHANGING TEXT> to be made to correspond to the particular section one happens to be reading? Thanks.

编辑:我试图使用

<script>
 document.getElementById("myBar").innerHTML = parseInt(scrolled.valueOf()*1.5); 

if (document.getElementById("myBar").innerHTML > 10)

{
<pf class="pos_fixed">
<div class="div1"><CHANGING TEXT></div>
</pf>
}

</script>

just to see if the <CHANGING TEXT> would appear after the tenth, but nothing at all happened. Could you please give an example with the IntersectionObserver. Should each section title have a tag, so that it can be referred to?

评论