jquery使日期选择器始终保持打开状态

发布于 2024-12-21 15:37:46 字数 89 浏览 3 评论 0原文

日期选择器的正常行为是在单击文本框时打开,在选择(单击)日期时关闭。我需要做的是保持它从表单加载中打开并允许用户重复单击。我正在处理单击事件,

谢谢

Normal behavior of datepicker is to open when a texbox is clicked and close when a date is selected(clicked). What I need to do is Keep it open from form load and allow user to click repeatedly.I am handling the click event

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清晰传感 2024-12-28 15:37:46

根据文档,您可以在 div 而不是输入上调用它,并且它将保持打开状态并内联。 http://jqueryui.com/demos/datepicker/#inline

您可以使用它的 onSelect 事件处理选择日期的情况。

According to the documentation, you can call it on a div instead of an input and it will stay open and be inline. http://jqueryui.com/demos/datepicker/#inline

You could use it's onSelect event to handle when a date is selected.

百思不得你姐 2024-12-28 15:37:46

如果您使用的是 jQuery UI 日期选择器,请使用:

http://jqueryui.com/demos/datepicker/ #inline

然后您可以处理点击事件并将所选日期添加到文本字段。

If you are using the jQuery UI datepicker, use this:

http://jqueryui.com/demos/datepicker/#inline

You can then handle the click event and add the selected date to the text field.

╄→承喏 2024-12-28 15:37:46

我完全同意@Corbin
我想提供完整的示例,以便详细帮助某人。

如果您想让 jQueryui 日历默认打开并捕获日历的点击事件,请按照以下步骤操作:

HTML 代码:

  <div id="myDatePicker" class="DateBox datepicker" style="width:100%;height:200px;"></div>
  <input type="hidden" id="dateHidden" name="dateHidden" />

您的脚本应如下所示:

<script>
  $( function() {
    $( ".datepicker" ).datepicker({ 
      altField: "#dateHidden",
      dateFormat: 'yy-mm-dd'})
     .datepicker("setDate", "0");
 } );
</script>

并且您可以像以下代码一样获取日期的选定值:

<script>

   $("#dateHidden").on('input propertychange paste', function(){

      var Loc = $("#Cafe").val();
      var PDate = $("#dateHidden").val();
      //------Functions you call or actions you perform--------//
      //GetLoc(Loc,PDate);

 });

</script>

I totally agree with @Corbin
I would like to provide full example so that help someone in details.

If you want to to have jQueryui calendar default open also capture the click event of calendar follow bellow steps:

HTML Code:

  <div id="myDatePicker" class="DateBox datepicker" style="width:100%;height:200px;"></div>
  <input type="hidden" id="dateHidden" name="dateHidden" />

and your script should look like bellow:

<script>
  $( function() {
    $( ".datepicker" ).datepicker({ 
      altField: "#dateHidden",
      dateFormat: 'yy-mm-dd'})
     .datepicker("setDate", "0");
 } );
</script>

and you can get the selected value of date like bellow code:

<script>

   $("#dateHidden").on('input propertychange paste', function(){

      var Loc = $("#Cafe").val();
      var PDate = $("#dateHidden").val();
      //------Functions you call or actions you perform--------//
      //GetLoc(Loc,PDate);

 });

</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文