jquery-ui时间选择插件

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>jQuery UI Datepicker - Select a Date Range</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
        <link rel="stylesheet" href="/resources/demos/style.css">
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        <script>
            $( function() {
    var dateFormat = "mm/dd/yy",
      from = $( "#from" )
        .datepicker({
          defaultDate: "+1w",
          changeMonth: true,
          numberOfMonths: 1
        })
        .on( "change", function() {
          to.datepicker( "option", "minDate", getDate( this ) );
        }),
      to = $( "#to" ).datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 1
      })
      .on( "change", function() {
        from.datepicker( "option", "maxDate", getDate( this ) );
      });
 
    function getDate( element ) {
      var date;
      try {
                let _datepicker=$.datepicker;
        date = $.datepicker.parseDate( dateFormat, element.value );//原生写法
      } catch( error ) {
        date = null;
      }
      return date;
    }
  } );
  </script>
    </head>
    <body>
        <label for="from">From</label>
        <input type="text" id="from" name="from">
        <label for="to">to</label>
        <input type="text" id="to" name="to">
    </body>
</html>

 

转载于:https://www.cnblogs.com/yg-home/p/9940490.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jquery-ui-timepicker-addon.css是基于jQuery UI的日期时间选择器插件datetimepicker的样式表文件,用于定义和控制datetimepicker组件的外观和样式。 datetimepicker插件是一个基于jQuery UI的日期时间选择器插件,它可以在输入框中集成日期和时间选择器,具有用户友好的界面和强大的可定制性。和其他jQuery UI组件一样,datetimepicker插件也需要相应的CSS文件来定义和控制其外观和样式。 jquery-ui-timepicker-addon.css文件是datetimepicker插件的样式表文件,它包含了datetimepicker的默认样式和主题,也可以用于自定义修改样式表文件以达到特定的视觉效果。 使用jquery-ui-timepicker-addon.css文件的方法和使用jquery-ui.css文件的方法类似,具体使用方法如下: 1. 下载datetimepicker插件和jQuery UI框架,从官网(https://jqueryui.com/)或其他来源下载datetimepicker插件和jQuery UI的压缩文件。 2. 引入jquery-ui-timepicker-addon.css文件,将jquery-ui-timepicker-addon.css文件复制到项目中,并在HTML页面中使用<link>标签引入该文件。 ``` <link rel="stylesheet" href="path/to/jquery-ui-timepicker-addon.css"> ``` 3. 引入jQuery和jQuery UI的JS文件,使用<script>标签引入jQuery和jQuery UI的JS文件。 ``` <script src="path/to/jquery.js"></script> <script src="path/to/jquery-ui.js"></script> ``` 4. 引入datetimepicker插件的JS文件,使用<script>标签引入datetimepicker插件的JS文件。 ``` <script src="path/to/jquery-ui-timepicker-addon.js"></script> ``` 引入这些文件后,就可以在输入框中集成日期时间选择器,并使用jquery-ui-timepicker-addon.css文件来控制其外观和样式了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值