function update() {
var container = document.getElementById("ItemContainer");
container.innerHTML = "";
for(var i=0;i<this.bookMarkList.length;i++){
var name = this.ItemContainer[i].name;
var tr = document.createElement('tr');
var td = document.createElement('td');
tr.appendChild(td);
tr.onclick = function(){add(name);};
container.appendChild(tr);
}
}
The same function is bound, but the parameters passed by each tr are different. How should it be written?
Now write like this, each tr is bound to the latest assigned parameter.
学习是最好的投资!