html collection数组转换成正常的dom对象数组

如果我们使用documen.getElementByClassName获取的数组,类型为html collection,需要转换成正常的dom对象数组

//删除所有的显示框,防止重复显示内容
var show-box= document.getElementsByClassName('show-box');
if (show-box.length > 0) {

  //将html collection转换为正常的数组
  Array.from(show-box).forEach(function (box, index) {
	box.remove();
  });

}

 

你可能感兴趣的:(javascript)