0
Set data attribute for each list items, use JavaScript dataset to identify clicked list item. function whit() { var liItems = document.querySelectorAll("#tabs li"); liItems.forEach( function(e) { e.addEventListener("click",changeActive.bind(e)); }); // if not support ES6, please use iterator } function changeActive() { alert(this.dataset.page); //access data-page attribute of clicked item } https://code.sololearn.com/W6G5zGe2emZk/?ref=app
12th Oct 2017, 11:46 AM
Calviղ
Calviղ - avatar