live vs static lists
/*
* Fiddle : http://jsfiddle.net/nzmwfufk/
* Réf : https://developer.mozilla.org/en-US/docs/Web/API/NodeList#A_.22live.22_collection
*/
/* test page : "chrome://apps/" 01/10/2013 */
var divs = document.querySelectorAll("div");
console.log('avant : ' + divs.length + ' items');
document.body.appendChild(document.createElement("div"));
console.log('après : ' + divs.length + ' items');
/* outputs :
avant : 113 items
après : 113 items
*/
/*******************************************/
var divs = document.getElementsByTagName("div");
console.log('avant : ' + divs.length + ' items');
document.body.appendChild(document.createElement("div"));
console.log('après : ' + divs.length + ' items');
/* outputs :
avant : 113 items
après : 114 items
*/