3

This code works very well in Google Chrome, but wont work in Internet Explorer:

document.getElementsByClassName('info')[i].remove();

Is there some other method to do the same thing or can I make .remove() work in Internet Explorer?

Panther
  • 3,312
  • 9
  • 27
  • 50
Thiago
  • 332
  • 1
  • 3
  • 16

1 Answers1

18

remove is not supported by ie

You would have to get the parent and call removeChild

var node = document.getElementsByClassName('info')[i];
node.parentNode.removeChild(node);

Also since you have jQuery tagged you could just do

jQuery(".info").eq(i).remove()

as jQuery does cross browser checks and uses the correct methods

Patrick Evans
  • 41,991
  • 6
  • 74
  • 87