如何预先填充jQuery Datepicker文本框与今天的日期? [英] How do I pre-populate a jQuery Datepicker textbox with today's date?

查看:87
本文介绍了如何预先填充jQuery Datepicker文本框与今天的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的jQuery Datepicker日历:

I have a very simple jQuery Datepicker calendar:

$(document).ready(function(){
    $("#date_pretty").datepicker({ 
    });
});

当然在HTML ...

and of course in the HTML...

<input type="text" size="10" value="" id="date_pretty"/>

今天的日期在用户启动日历时非常突出,但是如何获取jQuery预先填充文本框本身与页面加载的今天的日期,没有用户做任何事情? 99%的时间,今天的日期默认将是他们想要的。

Today's date is nicely highlighted for the user when they bring up the calendar, but how do I get jQuery to pre-populate the textbox itself with today's date on page load, without the user doing anything? 99% of the time, the today's date default will be what they want.

推荐答案

更新:有报告不再适用于Chrome。

这是简洁的,可以完成这项工作:

This is concise and does the job:

$(".date-pick").datepicker('setDate', new Date());

这篇关于如何预先填充jQuery Datepicker文本框与今天的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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