直接上代码:
var str = "";
document.writeln(" str += "\u65f6 for (h = 0; h <= 9; h++) { str += ""; } for (h = 10; h <= 24; h++) { str += ""; } str += " \u5206 for (m = 0; m <= 9; m++) { str += ""; } for (m = 10; m <= 59; m++) { str += ""; } str += " \u79d2 for (s = 0; s <= 9; s++) { str += ""; } for (s = 10; s <= 59; s++) { str += ""; } str += "
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 οnblur=\"hideSetTime()\"
这样便可以在div中加onblur事件。
你是不是也遇到这种问题呢?(*^__^*) 嘻嘻……