fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p>输入你的年龄并点击按钮:</p> <input id="age" value="18" /> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var age,voteable; age = document.getElementById("age").value; voteable = (age < 18) ? "太年轻而不能":"年龄够"; document.getElementById("demo").innerHTML = voteable + "投票"; } </script> </body> </html>
运行结果