/ Published in: JavaScript

You may perform this work with two ways: pass it directly like described in sample #1 or use an anonymous function like its shown in sample #2.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> // sample #1 setInterval('alert_function(1)', 1500); // sample #2 setInterval(function(){ alert_function(10); }, 1500); // user's alert function function alert_function(val){ alert("Passed parameter is: " + val); } </script>
URL: http://www.apphp.com/index.php?snippet=javascript-pass-parameters-in-setinterval
Comments
