0

Hi there I am using JQuery mobile to create a small app. For a part of the app I want to display the date and time to the user and them be unable to edit this. Currently I just have this:

div data-role="fieldcontain" class="ui-field-contain ui-body ui-br">Date:<br>
  <input type="datetime-local" name="date" id="date" value="" class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset">
</div>

I want to set this to the current date and time instead of the user being able to select for themselves. I have had a search but don't seem to be able to find much. I would really appreciate any help with this.

4

1 回答 1

1

正如 Rup 提到的,如果日期刚刚显示,您应该使用跨度而不是输入元素。如果没有任何东西要“放入”(语义..),那么输入就没有意义。您可以简单地使用 Date() 对象使用 javascript 生成当前日期,然后将其附加到您的 (span) 元素。也许你会发现这个答案很有帮助:javascript date object

于 2013-05-20T17:08:02.163 回答