使用type=date的时候input框中不显示空白

2024-10-14 14:18:02

1、当使用type=date的时候默认的在手机上是空白,在电脑上面也没有显示日期

使用type=date的时候input框中不显示空白

3、js代码:var now = new Date();//alert(now.getDate()+'-'+now.getMonth());//格式化日,如果小于9,前面补0var day = ("0" + now.getDate()).slice(-2);//格式化月,如果小于9,前面补0var month = ("0" + (now.getMonth() + 1)).slice(-2);//拼装完整日期格式var today = now.getFullYear()+"-"+(month)+"-"+(day) ;//完成赋值$('#createStartTime').val(today);

使用type=date的时候input框中不显示空白

5、这样在电脑和手机上面都有日期了。

使用type=date的时候input框中不显示空白
猜你喜欢