let overlay = document.createElement("div");
Object.assign(overlay,{id:"overlay"})
Table : API
Array.from(table.tBodies[0].rows).sort((rowA, rowB) => {
return +rowA.cells[col].textContent > +rowB.cells[col].textContent ? 1 : -1
});
Cours ↑ | TD ↑ | C ↑ |
---|---|---|
HTML | 100 | 1 |
CSS | 10 | 100 |
Js | 2 | 2 |
voir code ici ⇞
Array.from en action
Array.from
let headings = Array.from(document.querySelectorAll('article h1'), function(el) {return {
"pos": el.getBoundingClientRect().top,
"text": el.textContent
}
});
Event : scroll
window.addEventListener("scroll", function() {
if (window.pageYOffset <= headings[0].pos) {
document.querySelector(".current-section").classList.remove("show");
} else {
document.querySelector(".current-section").classList.add("show");
// Décomposition
for (let {pos,
text
} of headings) {
if (window.pageYOffset >= pos) {
document.querySelector(".current-section .name").textContent = text;
} else {
break;
}
}
}
}, false);
Inscription à :
Articles (Atom)