getElementById()不工作输入类型时间

getElementById() not working input type time

本文关键字:输入 类型 时间 工作 getElementById      更新时间:2023-09-26

为什么下面的代码不返回值?

<input type="time" id="hora" style="margin: 0 auto;" class="button button-block button-stable">

JS :

var hora = document.getElementById('hora').innerHTML; 
console.log(hora);

打印" "

为什么下面的代码不返回值?

因为输入元素没有innerHTML,它们有value:

var hora = document.getElementById('hora').value; 
console.log(hora);