Prev Demo
Passing Parameters To The Function In Set Time Out Method.
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Passing parameters to the function</h1> <p>Click the "Alert" button to get the alert after 4 seconds.</p> <input type="button" value="Alert" onclick="myFunction()"/> <p id="myId"></p> <script> var a; function myFunction() { a = setTimeout(myAlert, 4000, "First parameter"); } function myAlert(param1) { document.getElementById("myId").innerHTML += "WARNING!"; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output