How to create child nodes iteratable | Error: removeAttribute() is not a function
example: html:-------------------- <html> <body> <div id="bp"> <a href="1" id="idok" class="ok"> <a href="2" id="idrk" class="rk"> </div> </body> js:--------------------- /* I want to remove class attribute from a tags of bp div. The following code throws error: Uncaught TypeError: removeAttribute is not a function */ var obj=document.getElementById("bp"); mchild=obj.childNodes(); marray=[ ...mchild ]; for (var i=0; i<marray.length; i++) { marray[i].removeAttribute("class"); } /* However the following works - by directly creating array */ marray=[ document.getElementById("idok"), document.getElemenyById("idrk" ]; for (var i=0; i<marray.length; i++) { marray[i].removeAttribute("class"); } https://code.sololearn.com/WCSClkEmYPLG/?ref=app