<script>
$('#go').click(function () {
for (var i = 0; i < 5; i++) {
setTimeout(fun1(i),1000);
}
});
function fun1(index) {
console.log(index);
}
</script>
output- 0,1,2,3,4
$('#go').click(function () {
for (var i = 0; i < 5; i++) {
setTimeout(fun1(i),1000);
}
});
function fun1(index) {
console.log(index);
}
</script>
output- 0,1,2,3,4
No comments:
Post a Comment