I have a little problem here. My console.log(e) gives me the good result (1 or 2).
but the console.log(test) return me the integer variable. how can I store the function result in the test variable to use it later please ? Thx a lot !
const spans = selectPager.getElementsByTagName('span');
const test = function() {
for (let i = 0, len = spans.length; i < len; i++) {
(function(e) {
spans[i].onclick = function() {
console.log(e)
}
})(i);
}
}
test();
console.log(test);