Edit in JSFiddle

var myMap = new Map(),
    box = document.querySelectorAll(".box");

for(var i = 0; i < box.length; i++){
    //Associate the box content with the relevant DOM elements
    myMap.set(
        document.querySelectorAll(".box")[i],
        {content: "This is a box " + i}
    );
}

window.change = function change(){
    //Replace each element with the value's content
    myMap.forEach(function(value,key){
        key.innerHTML = value.content;
    });
}