Using jQuery Date picker with a custom trigger button

后端 未结 6 1533
伪装坚强ぢ
伪装坚强ぢ 2021-02-20 08:37

How do I make the jQuery Datepicker open up by a user defined button?

6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-20 09:13

    There's built-in support for this, having an icon or button to right right of the textbox, like this:

    $("#datepicker").datepicker({
      showOn: 'button',
      buttonImage: 'images/calendar.gif',
      buttonImageOnly: true
    });
    

    If you want to show it from another button, or really any event, call the show method, like this:

    $("#myButton").click(function() {
      $("#datepicker").datepicker("show");
    });
    

    You can try it here

提交回复
热议问题