日历中的输入类型html
问题描述:
该场景是,想在表td
中制作input type
框,并且它的右侧有一个日历图标。输入类型有placeholder "21-Jun-17"
和on click of input type a calendar should open.
我在寻找calendar api
,它符合我的需要,它应该是跨浏览器的?其次,日历图标应该位于输入的右侧?日历中的输入类型html
注意:上述场景应该适用于每个浏览器。
<html>
<body>
<tr>
<td>
<input type="text"> /`*logic to have a calendar icon at right and have a placeholder "21-Jun-17" and onclick open a small calendar where date is seletable*/`
</td>
</tr>
</body>
</html>
答
那么,有html5日期输入,它不需要任何定制,但有限的浏览器支持。
例子:
<input id="date" type="date">
了解更多:
如果你想这样在每个浏览器都能正常工作的情况下,您必须提出自己的解决方案,或者使用类似jQuery UI data picker的内容,这会带来很多臃肿。
答
这会有所帮助,
<html>
<body>
<tr>
<td>
<input type="date" id="date">
</input>
</td>
</tr>
</body>
<script>
document.getElementById("date").valueAsDate = new Date("2017-06-21");
</script>
</html>
+0
谢谢@Gowtham,但不适用于所有浏览器。 –
欢迎那你有没有尝试过的东西这么远吗?如果是,请粘贴你的努力。没关系,它不起作用,我们将检查并尝试为你纠正它 –
以及我试图把fontawesome图标,但它不可见。 –