Skip to content

Instantly share code, notes, and snippets.

@apphp-snippets
Created November 4, 2012 20:17
Show Gist options
  • Select an option

  • Save apphp-snippets/4013493 to your computer and use it in GitHub Desktop.

Select an option

Save apphp-snippets/4013493 to your computer and use it in GitHub Desktop.
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.
<script type="text/javascript">
/* Source: http://www.apphp.com/index.php?snippet=javascript-pass-parameters-in-setinterval */
// 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment