一、代码如下
二、运行效果如下
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <body> <h1>我的第一张网页</h1> <p id="demo"></p> <script> var price1 = 7; var price2 = 8; var price3 = 12; var total = price1 + price2 + price3; document.getElementById("demo").innerHTML = "总计:" + total; </script> </body> </html>