Jquery every () does not work in Internet Explorer

When I run the following JavaScript in IE, I get the message "Error: object does not support this property or method" for "data.every (...)".

This works in Chrome / Firefox.

alt text

+3
source share
3 answers

There is no method everydefined in jQuery. Instead, you can use each :

$.each(data, function(index, task) {
    createCardFromTask(task);
});

or a little shorter:

$.each(data, function() {
    createCardFromTask(this);
});
+6
source

.every()is a JavaScript 1.6 enhancement for the Array prototype. Firefox supports this method in Gecko 1.8b2 and later, and here is a quick replacement if it does not exist.

From MDC:

every - ECMA-262; , . , , , . Firefox SpiderMonkey.

if (!Array.prototype.every)
{
  Array.prototype.every = function(fun /*, thisp*/)
  {
    var len = this.length >>> 0;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this &&
          !fun.call(thisp, this[i], i, this))
        return false;
    }

    return true;
  };
}
+14

.each , DOM. , Javascript. HTML, , . ABBR, IE6.

, , IE6.

0

Source: https://habr.com/ru/post/1744732/


All Articles