I've been working on JavaScript lately, and everything was fine until I opened my page in IE11. as per Mozilla website .forEach
is supported from IE9.
This is the error I got.
SCRIPT438: Object doesn't support property or method 'forEach'
and this is the code.
var link1 = document.querySelectorAll("nav a");
var textbox = document.getElementById("OutputWindow");
link1.forEach(function (element) {
textbox.innerHTML += "<br/>" + element + "\n";
element.onclick = function () {
alert("Hello!");
console.log("hello!");
confirm("Hello!");
};
});
I tried polyfill, but to my amusement, Array
has a forEach
in IE11.
Then where I'm going wrong?
PS: This works fine in Chrome.