<div id="div"></div> <script> function abc(param) { alert(param); } var div = document.getElementById("div"); for (i=0; i< 6; i++) { div.innerHTML += "<a href='#' onClick='abc("+i+")'>blablabla</a><br>"; } </script>