Home >Web Front-end >JS Tutorial >A simple JS time control sample code (JS hour, minute, second time control)_javascript skills

A simple JS time control sample code (JS hour, minute, second time control)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:13:081401browse

I searched online for a long time and couldn’t find a control that only had “hours, minutes and seconds”, so I made one myself and posted it here for the convenience of others



The effect after mouse click

SetTime.js

Copy code The code is as follows:

/**//**********************************
* Instructions for use:
* First put This control is included in the page
*
* The control call function: _SetTime(field)
* For example
*
********************** *******************/
var str = "";
document.writeln("
");
str = "/u65f6 /u5206< select name=/"_minute/">";
for (m = 0; m <= 9; m ) {
str = "";
}
str = " /u79d2
";
document.writeln(str);
var _fieldname;
function _SetTime(tt) {
_fieldname = tt;
var ttop = tt.offsetTop; //The positioning point height of the TT control
var thei = tt.clientHeight; //The height of the TT control itself
var tleft = tt.offsetLeft; //The height of the TT control Anchor point width
while (tt = tt.offsetParent) {
ttop = tt.offsetTop;
tleft = tt.offsetLeft;
}
document.all._contents.style.top = ttop thei 4;
document.all._contents.style.left = tleft;
document.all._contents.style.visibility = "visible";
}
function _select() {
_fieldname.value = document.all._hour.value ":" document.all._minute.value ":" document.all._second.value;
document.all._contents.style.visibility = "hidden";
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn