navbar 随点击切换颜色
This commit is contained in:
parent
92db954631
commit
4149899000
6
main.js
6
main.js
@ -15,6 +15,12 @@ document.body.appendChild(header.flex({ justifyContent: 'space-between', alignIt
|
|||||||
link.style.padding = '.5rem'
|
link.style.padding = '.5rem'
|
||||||
link.style.borderRadius = '.25rem'
|
link.style.borderRadius = '.25rem'
|
||||||
link.style.color = (item.path === window.location.pathname) ? '#00C16A' : '#333'
|
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
|
return link
|
||||||
})),
|
})),
|
||||||
div.text('sign'),
|
div.text('sign'),
|
||||||
|
Loading…
Reference in New Issue
Block a user