[英]How to get second value from input time html tag to JavaScript variable
s1變量沒有獲得秒值,請在此處輸入代碼
function fun() { time=document.getElementById("time").value; h1=time[0]; h2=time[1]; m1=time[3]; m2=time[4]; s1=time[6];// Not Working document.getElementById("print").value=h1+""+h2+""+":"+m1+""+m2+":"+s1; } setInterval(fun,1000);
<p>Time:<p> <input type="time" id="time" name="time" step="1"></input><br> <input type="text" id="print"></input>
這是你想要的嗎?
function fun() { time=document.getElementById("time").value; h1=time[0]; h2=time[1]; m1=time[3]; m2=time[4]; s1=time[6]; s2=time[7]; document.getElementById("print").value = h1+""+h2+""+":"+m1+""+m2+":"+s1+""+s2; }
<p>Time:</p><input type="time" id="time" name="time" step="1"></input><br> <input type="text" id="print"></input>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.