Created
March 7, 2016 17:15
-
-
Save csdear/42bd92dcd649aa5805d1 to your computer and use it in GitHub Desktop.
Typical Web Page Jscript Wire Up I/O ABC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //WIRING A FUNCITON TO A UI ELEMENT : | |
| //• Conceptually | |
| // A. User Input to Trigger to Function Execution | |
| // B. Function Execution | |
| // C. Output | |
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <p>Click the button to get a time-based greeting:</p> | |
| //A. INPUT : wire to a element onclick | |
| <button onclick="myFunction()">Try it</button> | |
| //C2. OUTPUT : to the Innerhtml of a html element. | |
| <p id="demo"></p> | |
| //B. FUNCTION : Funciton Triggered in script by user interaction. | |
| <script> | |
| function myFunction() { | |
| var greeting; | |
| var time = new Date().getHours(); | |
| if (time < 10) { | |
| greeting = "Good morning"; | |
| } else if (time < 20) { | |
| greeting = "Good day"; | |
| } else { | |
| greeting = "Good evening"; | |
| } | |
| ////C1. OUTPUT : to the Innerhtml of a html element. | |
| document.getElementById("demo").innerHTML = greeting; | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment