zoukankan      html  css  js  c++  java
  • js小时分钟控件--

    直接上代码:


    var str = "";

    document.writeln("<div id="_contents" tabindex=9999 onblur="hideSetTime()" style="padding:6px; background-color:#E3E3E3; font-size: 12px; border: 1px solid #777777; position:absolute; left:?px; top:?px; ?px; height:?px; z-index:1; visibility:hidden">");

    str += "u65f6<select id="_hour"  style='65px' onchange='changeHour()'>";

    for (h = 0; h <= 9; h++) {

        str += "<option value="0" + h + "">0" + h + "</option>";

    }

    for (h = 10; h <= 24; h++) {

        str += "<option value="" + h + "">" + h + "</option>";

    }

    str += "</select> u5206<select id="_minute"  style='65px'>";

    for (m = 0; m <= 9; m++) {

        str += "<option value="0" + m + "">0" + m + "</option>";

    }

    for (m = 10; m <= 59; m++) {

        str += "<option value="" + m + "">" + m + "</option>";

    }

    str += "</select> u79d2<select id="_second"  style='65px;display:none;'>";

    for (s = 0; s <= 9; s++) {

        str += "<option value="0" + s + "">0" + s + "</option>";

    }

    for (s = 10; s <= 59; s++) {

        str += "<option value="" + s + "">" + s + "</option>";

    }

    str += "</select> <input name="queding" type="button" onclick="_select()" value="u786eu5b9a" style="font-size:12px" /></div>";

    document.writeln(str);

    var _fieldname;

    function _SetTime(tt) {

        _fieldname = tt;

        var ttop = tt.offsetTop;    //TT控件的定位点高

        var thei = tt.clientHeight;    //TT控件本身的高

        var tleft = tt.offsetLeft;    //TT控件的定位点宽

        while (tt = tt.offsetParent) {

            ttop += tt.offsetTop;

            tleft += tt.offsetLeft;

        }   

        document.getElementById("_contents").style.top = ttop + thei + 4+"px";

        document.getElementById("_contents").style.left = tleft+"px";

        document.getElementById("_contents").style.visibility = "visible";

        document.getElementById("_contents").focus();

    }

    function _select() {

        _fieldname.value = document.getElementById("_hour").value + ":" + document.getElementById("_minute").value;

        document.getElementById("_contents").style.visibility = "hidden";

    }

    function hideSetTime(){

    document.getElementById("_contents").style.visibility = "hidden";

    }

    function changeHour(){

    if(document.getElementById("_hour").value==24){ 

    _fieldname.value="24:00";

    document.getElementById("_contents").style.visibility = "hidden";

    }


    问题:如果是失去焦点的时候隐藏?

    解决:一般onblur事件是给form表单的input、按钮等使用,如果要给div、span、a.....等等这类标签使用的话,要加tabindex.

    tabindex=9999 onblur="hideSetTime()"

    这样便可以在div中加onblur事件。

    你是不是也遇到这种问题呢?(*^__^*) 嘻嘻……

  • 相关阅读:
    05---二叉树---20195106023---王亚威.c
    05---二叉树---20195106043---方传祥.c
    05---二叉树---20195106006---陈辉.c
    05---二叉树---20195106064---陈昕.c
    05---二叉树---20195106100---李遂勋.c
    2020下---3D建模---作业---blender
    nothing provides python(abi) = 3.8 needed by VirtualBox-6.1-6.1.16_140961_fedora32-1.x86_64
    el-table、pl-table(u-table)、ux-grid解决表格问题的实例(大数据量)
    1800*1【Codeforces Round #665 (Div. 2) D】Maximum Distributed Tree
    【Educational Codeforces Round 97 (Rated for Div. 2) C】Chef Monocarp
  • 原文地址:https://www.cnblogs.com/erpzj/p/5021972.html
Copyright © 2011-2022 走看看