• bom练习


           今天做了关于两个下拉框中的内容相互移动的特效。代码如下:

         

        <body>
        <select size="7" id="s1">
        <option>AAA</option>
        <option>BBB</option>
        <option>CCC</option>
        <option>DDD</option>
        <option>EEE</option>
        </select>
        <input type="button" id="to-right" value=">>>"/>
        <input type="button" id="to-left" value="<<<" />
        <select size="7" id="s2"></select>
        </body>

                     <script>

            var s1 = document.getElementById("s1");
          var s2 = document.getElementById("s2");
          var to_right = document.getElementById("to-right");
          to_right.onclick = function(){
          var obj_opt = s1.selectedOptions[0];
          var value = obj_opt.innerText;

          s2.appendChild(obj_opt)

                       }

                      

          to_left.onclick = function(){
          var obj_opt = s2.selectedOptions[0];
          var value = obj_opt.innerText;

          s1.appendChild(obj_opt)

                      }

                     </script>

                今天还做了关于时间日历的:

               

          <body>
          <select id="year" onchange="getDay()">
          <option>--请选择--</option>
          </select>
          <select id="month" onchange="getDay()">
          <option>--请选择--</option>
          </select>
          <select id="day"></select>
          </body>

                      

        <script>
        var time = new Date();
        var year = time.getFullYear();
        var obj_year = document.getElementById("year");
        var obj_month = document.getElementById("month");
        var obj_day = document.getElementById("day");

        for(var i = 1900; i <= year; i++) {
        obj_year.innerHTML += "<option>" + i + "</option>";
        }
        for(var i = 1; i <= 12; i++) {
        obj_month.innerHTML += "<option>" + i + "</option>";
        }

        function getDay() {
        obj_day.innerHTML = "";

        var month = obj_month.selectedOptions[0].innerText;
        var day31 = ["1", "3", "5", "7", "8", "10", "12"];
        var day30 = ["4", "6", "9", "11"];
        if(day31.indexOf(month) != -1) {
        for(var i = 1; i <= 31; i++) {
        obj_day.innerHTML += "<option>" + i + "</option>";
        }
        }
        if(day30.indexOf(month) != -1) {
        for(var i = 1; i <= 30; i++) {
        obj_day.innerHTML += "<option>" + i + "</option>";
        }
        }

        if(month == "2") {
        var yeared = obj_year.selectedOptions[0].innerText;
        if((yeared % 100 != 0 && yeared % 4 == 0) || yeared % 400 == 0) {
        for(var i = 1; i <= 29; i++) {
        obj_day.innerHTML += "<option>" + i + "</option>";
        }
        }else{
        for(var i = 1; i <= 28; i++) {
        obj_day.innerHTML += "<option>" + i + "</option>";
        }
        }

        }
        }
        </script>

  • 相关阅读:
    使用滤镜设置透明导致 IE 6/7/8/9 解析异常
    用事实证明cssText性能高
    字符串转成数字的多种方式
    IE6/7/8/9怪异模式和IE6标准模式中多余字符Bug
    将HTMLCollection/NodeList/伪数组转换成数组
    servlet下利用jsonlib
    JavaScript中同名标识符优先级
    JavaScript继承方式(3)
    设置HTML元素的透明度
    各浏览器中定位元素遮盖其它元素差异性
  • 原文地址:https://www.cnblogs.com/yujiamin123/p/6891147.html
Copyright © 2020-2023  润新知