css實現超出部分顯示省略號 display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;//行數 overflow: hidden;
var time = document.getElementById('time'); setInterval(function(){ //獲取當前時間 var d1 = new Date(); var d2=new Date(2018,3,23,19,0,0,0);//設定的截止時期,月份要減1 var dis = d2 - d1; var s = Math.round(dis/1000 % 60); var m = Math.floor(dis/1000/60%60); var h = Math.floor(dis/1000/60/60%24); var d = Math.floor(dis/1000/60/60/24); var str = d + "天" + h + "小時" + m + "分鐘" + s +"秒"; time.innerHTML = str; },1000);