zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 JAVASCRIPT开发学习:变量

    <!DOCTYPE html>
    <html>
    <head> 
    <meta charset="utf-8"> 
    <title>菜鸟教程(runoob.com)</title> 
    </head>
    <body>
    
    <p>点击这里来创建变量,并显示结果。</p>
    <button onclick="myFunction()">点击这里</button>
    <p id="demo"></p>
    <script>
    function myFunction(){
        var carname="Volvo";
        document.getElementById("demo").innerHTML=carname;
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head> 
    <meta charset="utf-8"> 
    <title>菜鸟教程(runoob.com)</title> 
    </head>
    <body>
    
    <p>假设 y=5,计算 x=y+2,并显示结果。</p>
    <button onclick="myFunction()">点击这里</button>
    <p id="demo"></p>
    <script>
    function myFunction(){
        var y=5;
        var x=y+2;
        var demoP=document.getElementById("demo");
        demoP.innerHTML="x=" + x;
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head> 
    <meta charset="utf-8"> 
    <title>菜鸟教程(runoob.com)</title> 
    </head>
    <body>
    
    <script>
    var x=5;
    var y=6;
    var z=x+y;
    document.write(x + "<br>");
    document.write(y + "<br>");
    document.write(z + "<br>");
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head> 
    <meta charset="utf-8"> 
    <title>菜鸟教程(runoob.com)</title> 
    </head>
    <body>
    
    <script>
    var pi=3.14;
    var name="Bill Gates";
    var answer='Yes I am!';
    document.write(pi + "<br>");
    document.write(name + "<br>");
    document.write(answer + "<br>");
    </script>
    
    </body>
    </html>

  • 相关阅读:
    CSS和Js样式属性的对照关系
    CSS选择器
    主成分分析(PCA)核心思想
    线性变换的本质
    java 滤镜实现
    Spring Boot工程发布到Docker
    解决maven的报错
    spring boot初探
    WPF的Page介绍及Page Window Frame 之间的链接使用示例,嵌套问题
    浅谈WPF页间导航
  • 原文地址:https://www.cnblogs.com/tszr/p/10941924.html
Copyright © 2011-2022 走看看