zoukankan      html  css  js  c++  java
  • JavaScript简介

    <html>
    <body>
    <p>JavaScript是属于网络的脚本语言!
    这门语言可用于HTML和web,更可广泛用于服务器、PC、平板电脑和智能手机登设备。
    <hr/>
    <h1>JavaScript:对事件作出反应</h1>
    </p>
    <button type="button" onclick="alert('welCome')">点击这里</button>
    <p>alert()函数在javaScript中并不常用,但它对于代码测试非常方便。</p>
    <hr/>//////////////////////////////////////////////////////////////////////////
    <h1>JavaScript:改变HTML内容</h1>
    <p>使用JavaScript来处理HTML内容是非常强大的功能</p>
    <p id="demo">JavaScript 能改变 HTML 元素的内容.</p>
    <script>
    function myFunction()
    {
    x=document.getElementById("demo"); //找到元素
    x.innerHTML="Hello JavaScript!" //改变内容
    }
    </script>
    <button type="button" onclick="myFunction()">点击这里</button>
    <hr/>/////////////////////////////////////////////////////////////////////
    <script>
    function changeImage()
    {
    element=document.getElementById("myImage"); //找到元素并赋值
    if(element.src.match("bulbon"))
    {
    element.src="/i/eg_bulboff.gif";
    }
    else
    {
    element.src="/i/eg_bulbon.gif";
    }
    }
    </script>
    <img id="myImage" onclick="changeImage()" src="/i/eg_bulboff.gif">
    <p>点击灯泡来点亮或熄灭这盏灯</p>
    <hr/>////////////////////////////////////////////////////////////////
    <h1>javaScript:改变HTML样式</h1>
    <p id="dem1">改变HTML的样式,属于改变HTML属性的变种</p>
    <script>
    function myFunction()
    {
    x=document.getElementById("dem1"); //找到元素
    x.style.color="#ff0000"; //改变样式
    }
    </script>
    <button type="button" onclick="myFunction()">点击这里</button>
    <hr/>///////////////////////////////////////////////////////////////
    <h1>javaScript:验证输入</h1>
    <p>请输入数字,如果输入值不是数字,浏览器会弹框提示</p>
    <input id="test1" type="text">
    <script>
    function test1(){
    x=document.getElementById("test1").value;
    if(x==""||isNaN(x))
    {
    alert("不是数字");
    }
    }
    </script>
    <button type="button" onclick="test1()">点击这里</button>
    </body>
    </html>

  • 相关阅读:
    Java基本数据类型的包装类
    Java数据类型基础
    Xscan安装
    Notepad++配置HexEditor插件
    [WP]XCTF-re2-cpp-is-awesome
    [WP]XCTF-tt3441810
    [WP]XCTF-re1-100
    [WP]XCTF-Mysterious
    [WP]xctf-parallel-comparator-200
    [WP]XCTF-elrond32
  • 原文地址:https://www.cnblogs.com/Knowledge-wealth/p/5703307.html
Copyright © 2011-2022 走看看