2021-03-03 00:13:50 +00:00
|
|
|
function bindClick( collToggle, collSection, i, j ) {
|
|
|
|
return function () {
|
|
|
|
j = i + 1;
|
|
|
|
this.classList.toggle( 'section-toggle--collapsed' );
|
|
|
|
collSection[ j ].classList.toggle( 'section-collapsible--collapsed' );
|
|
|
|
};
|
|
|
|
}
|
2021-03-02 22:16:24 +00:00
|
|
|
|
|
|
|
function main() {
|
|
|
|
var collSection = document.getElementsByClassName( 'section-collapsible' ),
|
|
|
|
collToggle = document.getElementsByClassName( 'section-toggle' ),
|
|
|
|
i, j;
|
|
|
|
|
2021-03-03 00:13:50 +00:00
|
|
|
for ( i = 0; i < collToggle.length; i++ ) {
|
|
|
|
collToggle[ i ].addEventListener( 'click', bindClick( collToggle, collSection, i, j ) );
|
2021-03-02 22:16:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|