Home  >  Article  >  Web Front-end  >  Iterate over time and compare sizes

Iterate over time and compare sizes

巴扎黑
巴扎黑Original
2016-11-25 13:49:042014browse

//Traverse the time period and append it to the drop-down list
var str;
for (var i = 1; i <=24; i++) {
for (var j = 0; j < 60; ) {
if(j==0 || i==24){
str=i+":"+j+"0";
}else{
str=i+":"+j;
}
$("#startTime" ).append("");
$("#endTime").append("");
if(j<60) j+=10;
if(i==24) break;
// if(j>=50){
// j+=9;
// }else{
// j+=10;
// }
}
}


//Compare the size of two characters

function addTime(){
var hour_select_begin=$ ('#startTime option:selected').text();
var hour_select_end=$('#endTime option:selected').text();
// alert(hour_select_begin+":"+hour_select_end+"_"+eval( "hour_select_begin"));

if(eval("hour_select_begin")>=eval("hour_select_end")){
alert("The end time cannot be less than or equal to the start time");
return false;
}


}

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