当前位置: 动力学知识库 > 问答 > 编程问答 >

internet explorer 8 - JQuery .forEach not supported in IE8. Is there a work around?

问题描述:

I have the following code block working in IE9 correctly

data.forEach(function loadClips(value) {

//console.log("URL of the show is " + value.Images[0].Url);

var href = '/video/player.aspx?vid=' + value.Id;

var title = value.ShortDesc;

"</a></li>");

})

But it doesn't work in IE8. Instead of .forEach, i tried .each(), it doesn't work either. Any ideas on what the correct solution should be? many thanks

网友答案:

This should do it (don't forget the last semi-colon)

 $.each(data, function loadClips(value) {
    //console.log("URL  of the show is " + value.Images[0].Url);
    var href = '/video/player.aspx?vid=' + value.Id;
    var title = value.ShortDesc;


 "</a></li>");                         


});
网友答案:

forEach is not a jQuery function. See support for Array.prototype.forEach.

Instead, you can use

$(array).each(function (index, item) { doSomething(item); });

See documentation

网友答案:

i just iterate it through a traditional for loop, as supposed to forEach and that worked for IE8

分享给朋友:
您可能感兴趣的文章:
随机阅读: