navbar 随点击切换颜色

This commit is contained in:
2024-08-17 20:01:53 +08:00
parent 92db954631
commit 4149899000

View File

@ -15,6 +15,12 @@ document.body.appendChild(header.flex({ justifyContent: 'space-between', alignIt
link.style.padding = '.5rem'
link.style.borderRadius = '.25rem'
link.style.color = (item.path === window.location.pathname) ? '#00C16A' : '#333'
link.onclick = (event) => {
event.preventDefault()
window.history.pushState({}, '', event.target.href)
Array.from(event.target.parentElement.children).forEach(x => x.style.color = '#333')
event.target.style.color = '#00C16A'
}
return link
})),
div.text('sign'),