mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-21 13:39:30 -07:00
feat(nav.ts): add functionality to set the current link based on the currentMenuItemIndex attribute
This commit is contained in:
@@ -31,6 +31,24 @@ const indexDispNums = Array.from(
|
|||||||
indexDiv.getElementsByClassName('num')
|
indexDiv.getElementsByClassName('num')
|
||||||
) as HTMLSpanElement[]
|
) as HTMLSpanElement[]
|
||||||
|
|
||||||
|
// links div
|
||||||
|
const linksDiv = document.getElementsByClassName('links').item(0) as HTMLDivElement
|
||||||
|
|
||||||
|
// links
|
||||||
|
const links = Array.from(linksDiv.getElementsByClassName('link')) as HTMLAnchorElement[]
|
||||||
|
|
||||||
|
// current link index
|
||||||
|
const currentLinkIndex = document
|
||||||
|
.getElementById('main')!
|
||||||
|
.getAttribute('currentMenuItemIndex') as string
|
||||||
|
|
||||||
|
// set current link
|
||||||
|
for (let [index, link] of links.entries()) {
|
||||||
|
if (index === parseInt(currentLinkIndex)) {
|
||||||
|
link.classList.add('current')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init
|
* init
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user