In this JavaScript Tutorial, we will create a function called greet() which does not receive and any parameter and does not return anything to the caller. Then we will invoke this JavaScript function from a HTML OnClick Button event.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<!DOCTYPE HTML> <HTML> <HEAD> <TITLE>Learn Java Script</TITLE> <script type="text/javascript" > function Greet() { var GreetMsg = "Hello Welcome Back!"; document.getElementById("h3Out").innerHTML = GreetMsg; } </script> </HEAD> <BODY> <H1> JavaScript Functions Example </H1> <br/> <input type="button" value="Call Greet" onclick="Greet()" /> <h3 id="h3Out"></h3> </BODY> </HTML> |
Categories: JavaScript-Tube