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

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

问题描述

我需要在链接点击上显示 jquery datepicker ,当选择日期将链接文本更改为此日期时,我该怎么办

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

推荐答案

jQuery UI日期选择器应该做这个工作。

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

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

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

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');
    });

要在选择日期后更改链接文本,请在初始化代码中使用类似的内容: p>

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天全站免登陆