如何在链接点击时显示 jquery datepicker? [英] How to display jquery datepicker on link click?

查看:21
本文介绍了如何在链接点击时显示 jquery datepicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在链接上显示 jQuery UI 日期选择器点击,同样在选择日期时将链接文本更改为该日期,我该怎么做?

解决方案

jQuery UI 日期选择器应该完成工作.

查看使用图标触发选择器的示例:http://jqueryui.com/demos/datepicker/#icon-trigger>

您也可以在需要时调用 show() 方法来下拉选择器,例如...

$('#mypicker').datepicker({//选项minDate: '20.04.2012'//...});$('#mylink').click(function(){$('#mypicker').datepicker('show');});

要在选择日期后更改链接文本,请在初始化代码中使用以下内容:

$('#mypicker').datepicker({ onSelect:功能(日期文本,inst){$('#mylink').text(dateText);}});

I need to show jQuery UI datepicker on link click, also when a date is picked change link text to this date, how can I do it?

解决方案

jQuery UI date picker should do the job.

Check out the example using an icon to trigger the picker: http://jqueryui.com/demos/datepicker/#icon-trigger

You can also call the show() method to drop down the picker whenever you need to, e.g...

$('#mypicker').datepicker({
      //options
      minDate: '20.04.2012'
      //...
    });
$('#mylink').click(function(){
      $('#mypicker').datepicker('show');
    });

To change the link text after a date is selected, use something like this in initialization code:

$('#mypicker').datepicker({ onSelect:
    function(dateText, inst) {
        $('#mylink').text(dateText);
    }
});

这篇关于如何在链接点击时显示 jquery datepicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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