Javascript examples for Function:Function Definition
Click on a button to call a function, which will output "Hello World" in an element with id="demo":
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Click me</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j a va 2s . c o m document.getElementById("demo").innerHTML = "Hello World"; } </script> </body> </html>