Skip to content

Convert NodeList to Array for a Stepper to work with IE

I want to create a simple Vanilla JS horizontal stepper without the addition of CSS or JS libraries. I have found this example but it doesnt work with IE browser. The problem is the following line:

const  bullets  =  [...document.querySelectorAll('.bullet')];

where he is converting the NodeList of ‘divs’ with class .bullet to Array. Is there any way to make it work because I have tried “Array.prototype.slice” and copy the Nodelist in a JS array without success..



I would just iterate though the the nodeList with something like a for loop and add the nodelist item to the array . Something like this:

let bulletsArray = [];
let bullets = document.querySelectorAll('bullets');
for(let i = 0; i < bullets.length; i++) {

Heres a working demo: Note: my initial idea was to use Array.from() but after checking its compatibility list on mdn i noticed that it isnt supported in IE

User contributions licensed under: CC BY-SA
5 People found this is helpful