var span=document.getElementById('banner');for(var i=0; i<4; i++) { var a = document.createElement('a'); a.onclick = "show("+i+")"; a.innerHTML = (i+1); span.appendChild(a);}