- html>
- <html>
- <head>
- <meta charset = "UTF-8"/>
- <title>title>
- head>
- <body>
- <p>JavaScript 运算符p>
- <h3>HTMLh3>
- <p id = "demo">p>
- <script>
- document.getElementById("demo").innerHTML = (10 + 9) * 3;
- script>
- body>
- html>
JavaScript 运算符
JavaScript 使用算数运算符(+ - * /)来计算值
- html>
- <html>
- <head>
- <meta charset = "UTF-8"/>
- <title>title>
- head>
- <body>
- <p>JavaScript 使用赋值运算符htmlp>
- <h3>html
- <p id = "demo2">p>
- <p id = "demo3">p>
- <script>
- var y,k;
- y = 10;
- k = 9;
- document.getElementById("demo2").innerHTML = k + y;
- script>
- body>
- html>
JavaScript 使用赋值运算符(=)向变量赋值
- html>
- <html>
- <head>
- <meta charset = "UTF-8"/>
- <title>title>
- head>
- <body>
- <p>JavaScript 表达式p>
- <h3>JavaScript 表达式h3>
- <p id = "demo3">p>
- <script>
- document.getElementById("demo3").innerHTML = 3 * 10;
- script>
- body>
- html>
JavaScript 表达式
表达式是值、变量和运算符的组合,计算结果是值
- html>
- <html>
- <head>
- <meta charset = "UTF-8"/>
- <title>title>
- head>
- <body>
- <p>JavaScript 表达式p>
- <h3>JavaScript 表达式h3>
- <p id = "demo5">p>
- <script>
- var v;
- v = 100;
- document.getElementById("demo5").innerHTML = v * 10;
- script>
- body>
- html>
JavaScript 表达式
表达式也可包含变量值
- html>
- <html>
- <head>
- <meta charset = "UTF-8"/>
- <title>title>
- head>
- <body>
- <p>JavaScript 表达式p>
- <h3>JavaScript 表达式h3>
- <p id = "demo9">p>
- <script>
- document.getElementById("demo9").innerHTML = "HTML" + "" +"css"
- script>
- body>
- html>
JavaScript 表达式
值可以是多种类型,比如数值和字符串。
- html>
- <html>
- <head>
- <meta charset = "UTF-8"/>
- <title>title>
- head>
- <body>
- <p>p>
- <h3>h3>
- <p id = "demo0">p>
- <p id = "demo10">p>
- <script>
- var h,q;
- h = 9 * 10;
- q = h * 10;
- document.getElementById("demo0").innerHTML = h;
- document.getElementById("demo10").innerHTML = q;
- script>
- body>
- html>
JavaScript 关键词
JavaScript 关键词用于标识被执行的动作