highlight menu on scrolling (if reach div)

后端 未结 2 896
逝去的感伤
逝去的感伤 2021-02-05 08:30

i want highlight the menu point if the div is scrolled // or clicked.

http://jsfiddle.net/WeboGraph/vu6hN/2/ (thats an example what i want)

my code: (JS)

<
2条回答
  •  盖世英雄少女心
    2021-02-05 09:19

    Found this in 2018 and ran into a syntax error trying to replicate with a more recent version of jquery (+1.0). In the last line $('nav a[href=#'+ id +']') the attribute is not properly escaped and needs to be like so $('nav a[href="#'+ id +'"]') (note added "").

    Here's where I found this https://api.jquery.com/attribute-contains-selector/

提交回复
热议问题