zoukankan      html  css  js  c++  java
  • 二、innerHTML应用测试

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>innerHTML测试页面</title>

    <script>


    function Test(){
    var str="";
    str+="Hello,";
    str+="This is a Test!<br />";
    str+="I Love you;<br />";
    str+="I Love you,too!";
    p.innerHTML=str+"<br /><br />"+Math.random();
    setTimeout('Test();',1000);
    }
    function chageDiv(number)
    {
    if (number == 1) {
    document.getElementById("div").innerHTML = "值为1";
    }
    if (number == 2) {
    document.getElementById("div").innerHTML = "值为2";
    }
    }
    function chageA(number)
    {
    if (number == 1) {
    document.getElementById("A").innerHTML = "值为1";
    }
    if (number == 2) {
    document.getElementById("A").innerHTML = "值为2";
    }
    }
    </script>

    </head>
    <body onload="Test()">

    <span id="p"></span><br><br>

    innerHTML传值测试(DIV块):<br><br>
    <div id="div" style=" 180px;height:120px;color: red ;font-size: 30px;background: green"> DIV块 </div>
    <a href="#" onClick="chageDiv(1)">改变值为1</a>
    <a href="#" onClick="chageDiv(2)">改变值为2</a><br><br>

    innerHTML传值测试(a标签):<a id="A" style="font-size: 38px;color: red"> a标签</a><br>
    <a href="#" onClick="chageA(1)">改变值为1</a>
    <a href="#" onClick="chageA(2)">改变值为2</a>

    <script type="text/javascript">
    function chageSpan(number)
    {
    if (number == 1) {
    document.getElementById("span1").innerHTML = "值为1";
    }
    if (number == 2) {
    document.getElementById("span1").innerHTML = "值为2";
    }
    }
    </script>
    <br><br>
    <div>
    Span行测试:

    <span id="span1" style="font-size: 30px;color: red">默认值</span><br>
    <a href="#" onClick="chageSpan(1)">改变值为1</a>
    <a href="#" onClick="chageSpan(2)">改变值为2</a>

    </div>

  • 相关阅读:
    gazebo自建小车备忘
    关于hokuyo的一些参数的备忘
    xenserver加入池报错The servers in this pool are not homogeneous
    exchange管理控制台初始化失败--Kerberos连接失败
    修复windows系统更新失败
    powershell同步时间
    powershell创建密文密码文件
    powershell常用命令
    Graylog客户端及服务端
    powershell,cmd,shell查看帮助
  • 原文地址:https://www.cnblogs.com/frankchia/p/6216086.html
Copyright © 2011-2022 走看看