2015-05-30 2 views

ответ

4

Я хотел бы предложить следующее:

// using Function.prototype.call() to apply 
// Array.prototype.map() to the array-like NodeList returned 
// by document.querySelectorAll(): 
var elementIDs = Array.prototype.map.call(document.querySelectorAll('.cookie'), function (cookie) { 
    // the first argument to the anonymous function ('cookie') is 
    // the array element of the array over which we're iterating, 
    // and is here a DOM node. 

    // here, we return the id property of the current node: 
    return cookie.id; 
}); 

Ссылки: