Prev Demo
Passing Parameters To Functions In Javascript
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <p>Click the 'Start' button to alert "TechFunda" on the sceen for every 3 seconds.</p> <input type="button" value="Start" onclick="myStart()"/><input type="button" value="Stop" onclick="myStop()"/> <p id="myId"></p> <script> var a; function myStart() { a = setInterval(myAlert, 3000, "First parameter"); } function myAlert(param1) { document.getElementById("myId").innerHTML += "TechFunda"; } function myStop() { clearInterval(a); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output