22 lines
507 B
JavaScript
22 lines
507 B
JavaScript
|
|
function say_hello() {
|
|
console.log("Hello World");
|
|
}
|
|
|
|
function register_nav_links() {
|
|
var navAnchors = document.querySelectorAll("nav a");
|
|
|
|
navAnchors.forEach(function (a_el) {
|
|
a_el.addEventListener("click", nav_a_click);
|
|
});
|
|
}
|
|
|
|
function nav_a_click(event) {
|
|
var active_anchor = document.querySelector("nav a.active");
|
|
active_anchor.classList.remove("active");
|
|
|
|
var clicked = event.target;
|
|
clicked.classList.add("active");
|
|
}
|
|
|
|
export {say_hello, register_nav_links};
|