Jquery日期选择器年份订单 [英] Jquery date picker year order

查看:77
本文介绍了Jquery日期选择器年份订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码在这里用于Jquery日期选择器

  //来自jQuery UI插件的Datepicker 
$ birth .datepicker({
onSelect:function(dateText,inst){
$(this).parent()。find(label#error)。html();
$
$ R
$ R $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b $ b selectOtherMonths:true,
dateFormat:'yy-mm-dd'
});
});

我的年下降开始于1950年,一直到2006年,我想扭转他们。



我试过 yearRange:'2006:1950'但没有显示:(



有没有解决这个问题?

解决方案

提供的链接是一个很好的解决方案另一种方式是一种黑客,但有用:
http://plnkr.co/编辑/ sSdUbqd1pWKyiBOZAMwD?p =预览

  $(document).ready(function(){

var showPicker = false;

$(#txtBirthday)。datepicker({
onSelect:function(dateText,inst){
$(this) parent()。find(label#error)。html();
$ gender.focus();
},
yearRange:'1950:2006',
changeMonth:true,
changeYear:true,
showOtherMonths:true,
selectOtherMonths:true,
date格式:'yy-mm-dd',
onClose:function(dateText,inst){
showPicker = false;
}
});

$(。ui-datepicker)。on(mouseenter,function(){

if(!showPicker){
showPicker = true;

//反转年份
var dropYear = $(select.ui-datepicker-year);

dropYear.find('option')。 each(function(){
dropYear.prepend(this);
});

}

});

});


I have this code here for a Jquery date picker

// Datepicker from jQuery UI plugin
    $birth.datepicker({
    onSelect: function(dateText, inst) { 
        $(this).parent().find("label#error").html("");
        $gender.focus();
    },
        yearRange: '1950:2006',
        changeMonth: true,
    changeYear: true,           
    showOtherMonths: true,          
    selectOtherMonths: true,
    dateFormat: 'yy-mm-dd'
    });
});

My year dropdown starts at 1950 and goes all the way to 2006, I would like to reverse them..

I tried yearRange: '2006:1950' but nothing displayed :(

Is there away to fix this?

解决方案

The link supplied is a good solution. Here is another way that is kind of a hack but works: http://plnkr.co/edit/sSdUbqd1pWKyiBOZAMwD?p=preview

$(document).ready(function() {

  var showPicker = false;

  $("#txtBirthday").datepicker({
    onSelect: function(dateText, inst) {
      $(this).parent().find("label#error").html("");
      $gender.focus();
    },
    yearRange: '1950:2006',
    changeMonth: true,
    changeYear: true,
    showOtherMonths: true,
    selectOtherMonths: true,
    dateFormat: 'yy-mm-dd', 
    onClose: function(dateText, inst) {
      showPicker = false;
    }
  });

  $(".ui-datepicker").on("mouseenter", function() {

    if (!showPicker) {
      showPicker = true;

      //Reverse the years
      var dropYear = $("select.ui-datepicker-year");

      dropYear.find('option').each(function() {
        dropYear.prepend(this);
      });

    }

  });

});

这篇关于Jquery日期选择器年份订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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