在iPad上设置日期输入的值 [英] Setting the value of date inputs on iPad

查看:129
本文介绍了在iPad上设置日期输入的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WEB APP 不是原生的,没有Objective-C

WEB APP not native, no Objective-C

这很简单就会伤害。

  <input type="date" />

完成使用iPad原生日期选择器。然后用jQuery设置初始值

Done to use the iPad native datepicker. Then setting the initial value with jQuery

  $('input[type="date"]').val('Jun 25, 2012');

导致空输入字段。上面的jQuery在ie7-9,chrome,safari和FF中运行得很好,但在iOS中却不行!

Resulting in an empty input field. The jQuery above works great in ie7-9, chrome, safari, and FF, but not in iOS!

我没有想法。有谁知道一个工作?或者为什么会发生这种情况?

I am out of ideas. Does anyone know a work around? Or why this happens?

推荐答案

尝试在iOS 5上使用Safari

Try this for Safari on iOS 5

 $('input[type="date"]').val('yyyy-MM-dd');

您可以从您使用的日期类型转换为 yyyy使用 Date()函数在JavaScript中使用-MM-DD

You could do the conversion from the type of Date you are using to yyyy-MM-DD in JavaScript using the Date() function.

这篇关于在iPad上设置日期输入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆