diaporamaMiscWeb
 
◃  Ch. 3 Ajax  ▹
 

Taquin amélioré

function initEventHandlers() {
    var cells = document.getElementsByTagName('td');
    var nbCells = cells.length;
    for(var i=0; i<nbCells; ++i) {
	var cell = cells.item(i);
	cell.addEventListener('click',taquin,false);
  }
}
window.addEventListener('load',initEventHandlers,false)
function taquin(e) {
  var cell = e.target;
...
}