• 随笔


    <style>
    #div1{
    100px;
    height: 100px;
    background-color: red;
    }
    </style>
    </head>

    <body>
    <div id="divid"></div>
    <div class="divclass"></div>
    <div class="divclass"></div>
    <input name="inputname" type="text" />
    <input type="button" onclick="btn()" />
    <div id="test"></div>
    <!--<div id="czsx" style=" 200px;height: 200px; border: 1px solid black;">
    123
    </div>-->
    <table id="czsx">
    <tr>
    <td>123</td>
    </tr>
    </table>

    <input id="btn-cz" type="button" value="提交" />
    <div id="div1"></div>
    <script>
    // var count = 0;
    // for(var i = 3; i < 1001; i++) {
    // var status = 0;
    // for(var j=2;j<i;j++){
    // if(i%j ==0)
    // {
    // status = 1;
    // break;
    // }
    // }
    // if(status ==0)
    // {
    // document.write(i + "<br>");
    // count++;
    // }
    // }
    // alert(count);

    // document.alert("弹窗");
    // window.alert("弹窗");
    // 1.id选择器
    document.getElementById("divid").innerHTML = "啦啦啦啦啦";
    // 2.class选择器
    var divc = document.getElementsByClassName("divclass");
    // alert(typeof(divc));
    divc[0].innerHTML = "嘿嘿嘿嘿";
    divc[1].innerHTML = "哈哈哈哈";
    for(var i = 0 ;i<divc.length;i++)
    {
    divc[i].innerHTML += "略略略略";
    }
    // 3.标签选择器
    document.getElementsByTagName("div")[0].innerHTML += "耶耶耶耶";
    // 4.name选择器
    document.getElementsByName("inputname")[0].value = "哒哒哒嗒";
    var input = document.getElementsByName("inputname")[0].value;
    // alert(input);

    function btn(){
    var div1 = document.getElementById("divid");
    div1.innerHTML += "oooooooo";
    }

    // document.getElementById("test").innerHTML = "<b>加粗</b>";
    document.getElementById("test").innerText = "<b>加粗</b>";

    document.getElementById("czsx").setAttribute("bgcolor","red");

    document.getElementById("btn-cz").setAttribute("disabled","disabled");
    document.getElementById("btn-cz").removeAttribute("disabled");
    var btn_cz = document.getElementById("btn-cz").getAttribute("value");
    // alert(btn_cz);
    var div1 = document.getElementById("div1");
    // div1.setAttribute("style"," 200px;height:200px;background-color: red;");

    // div1.style.width = "100px";
    // div1.style.height = "100px";
    // div1.style.backgroundColor = "red";

    alert(div1.style.width);
    </script>

    </body>

  • 相关阅读:
    常用 JS代码
    java中的变量各占得字节数
    70种简单好用的js代码
    JavaScript window.document的属性、方法和事件小结
    JS的event对象使用总结
    PHP魔术函数执行时间和顺序解析
    javascript event详解
    JS获取鼠标点击对象
    ThinkPHP实例化模型的四种方法
    实践:服务器编写/系统架构/cache
  • 原文地址:https://www.cnblogs.com/gyzown/p/6606103.html
Copyright © 2020-2023  润新知