源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <h1>JavaScript 变量</h1> <p>字符串是用引号括住.</p> <p>数字不用双引号.</p> <p>删除注释前面的 // 测试一下.</p> <p id="demo"></p> <script> var pi = 3.14; var person = "John Doe"; var answer = 'Yes I am!'; document.getElementById("demo").innerHTML = pi; //document.getElementById("demo").innerHTML = person; //document.getElementById("demo").innerHTML = answer; </script> </body> </html>
运行结果