time.html代码:
复制代码 代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.8.2.min.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/time.js"></head>
<body>
<input type="button" value="小时加" onClick="add_hour();">
<input type="text" value="00" id="hour">
<input type="button" value="小时减" onClick="sub_hour();">
<br/>
<br/>
<input type="button" value="分钟加" onClick="add_minute();">
<input type="text" value="00" id="minute">
<input type="button" value="分钟减" onClick="sub_minute();">
</body>
</html>
time.js代码:
复制代码 代码如下:
function add_num(a,b,c){
if(c<a){
c++;
}
else{
c=b;
}
if(c<=9&&c>=0){
c="0"+c;
}
return c;
}
function sub_num(a,b,c){
if(c>a){
c--;
}
else{
c=b;
}
if(c<=9&&c>=0){
c="0"+c;
}
return c;
}
function add_hour(){
var current_num=$("#hour").attr("value");
current_num=add_num(23,0,current_num);
$("#hour").attr("value",current_num);
}
function sub_hour(){
var current_num=$("#hour").attr("value");
current_num=sub_num(0,23,current_num);
$("#hour").attr("value",current_num);
}
function add_minute(){
var current_num=$("#minute").attr("value");
current_num=add_num(59,0,current_num);
$("#minute").attr("value",current_num);
}
function sub_minute(){
var current_num=$("#minute").attr("value");
current_num=sub_num(0,59,current_num);
$("#minute").attr("value",current_num);
}
复制代码 代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.8.2.min.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/time.js"></head>
<body>
<input type="button" value="小时加" onClick="add_hour();">
<input type="text" value="00" id="hour">
<input type="button" value="小时减" onClick="sub_hour();">
<br/>
<br/>
<input type="button" value="分钟加" onClick="add_minute();">
<input type="text" value="00" id="minute">
<input type="button" value="分钟减" onClick="sub_minute();">
</body>
</html>
time.js代码:
复制代码 代码如下:
function add_num(a,b,c){
if(c<a){
c++;
}
else{
c=b;
}
if(c<=9&&c>=0){
c="0"+c;
}
return c;
}
function sub_num(a,b,c){
if(c>a){
c--;
}
else{
c=b;
}
if(c<=9&&c>=0){
c="0"+c;
}
return c;
}
function add_hour(){
var current_num=$("#hour").attr("value");
current_num=add_num(23,0,current_num);
$("#hour").attr("value",current_num);
}
function sub_hour(){
var current_num=$("#hour").attr("value");
current_num=sub_num(0,23,current_num);
$("#hour").attr("value",current_num);
}
function add_minute(){
var current_num=$("#minute").attr("value");
current_num=add_num(59,0,current_num);
$("#minute").attr("value",current_num);
}
function sub_minute(){
var current_num=$("#minute").attr("value");
current_num=sub_num(0,59,current_num);
$("#minute").attr("value",current_num);
}
标签:
按钮,控制文本框,加1减1
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“使用js实现按钮控制文本框加1减1应用于小时+分钟”评论...