如何在按钮单击上显示一个jQuery datepicker [英] how to show a jquery datepicker on button click

查看:132
本文介绍了如何在按钮单击上显示一个jQuery datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在单击按钮时显示日期选择器

I want to show a datepicker only on button click

<input type="button" id=day value="day" />
$("#day").datepicker();

上面的行用选定的日期填充按钮文本

the above line fills the button text with the selected date

我也尝试了下面的代码,但是什么也没发生

I have also tried with below code but nothing happens

$("#day").click(function() {
    $("#hiddenField").datepicker('show');
});

推荐答案

您可以使用内置的showOn函数来做到这一点:

You can do this with the built-in showOn function:

$( "#hiddenField" ).datepicker({
    showOn: "button",
    buttonText: "day"
});

JSFiddle: http://jsfiddle.net/Uv8V4/

JSFiddle: http://jsfiddle.net/Uv8V4/

参考: http://jqueryui.com/datepicker/#icon-trigger

这篇关于如何在按钮单击上显示一个jQuery datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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