开发者社区 问答 正文

jQuery之datePicker()的使用

初学jQuery哪位帮帮解决下小问题 红框部分日期不能选择 怎么开启啊
screenshot

展开
收起
a123456678 2016-07-05 10:27:37 2072 分享 版权
1 条回答
写回答
取消 提交回答
  • jQuery(function(){
    
     $("#datePicker").datePicker({
    
     createButton:false,
    
     clickInput:true,
    
     setSelected: (1900, 1 - 1, 1)
    
     });
    
     
    
    });
    
    这是我自定你故意的js
    
    /**
    
     * Copyright (c) 2008 Kelvin Luck (http://www.kelvinluck.com/)
    
     * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
    
     * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
    
     * .
    
     * $Id: jquery.datePicker.js 98 2010-05-24 10:10:01Z kelvin.luck $
    
     **/
    
    (function($){
    
     $.fn.extend({
    
    /**
    
     * Render a calendar table into any matched elements.
    
     * 
    
     * @param Object s (optional) Customize your calendars.
    
     * @option Number month The month to render (NOTE that months are zero based). Default is today's month.
    
     * @option Number year The year to render. Default is today's year.
    
     * @option Function renderCallback A reference to a function that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Default is no callback.
    
     * @option Number showHeader Whether or not to show the header row, possible values are: $.dpConst.SHOW_HEADER_NONE (no header), $.dpConst.SHOW_HEADER_SHORT (first letter of each day) and $.dpConst.SHOW_HEADER_LONG (full name of each day). Default is $.dpConst.SHOW_HEADER_SHORT.
    
     * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class.
    
     * @type jQuery
    
     * @name renderCalendar
    
     * @cat plugins/datePicker
    
     * @author Kelvin Luck (http://www.kelvinluck.com/)
    
     *
    
     * @example $('#calendar-me').renderCalendar({month:0, year:2007});
    
     * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me.
    
     *
    
     * @example
    
     * var testCallback = function($td, thisDate, month, year)
    
     * {
    
     * if ($td.is('.current-month') && thisDate.getDay() == 4) {
    
     * var d = thisDate.getDate();
    
     * $td.bind(
    
     * 'click',
    
     * function()
    
     * {
    
     * alert('You clicked on ' + d + '/' + (Number(month)+1) + '/' + year);
    
     * }
    
     * ).addClass('thursday');
    
     * } else if (thisDate.getDay() == 5) {
    
     * $td.html('Friday the ' + $td.html() + 'th');
    
     * }
    
     * }
    
     * $('#calendar-me').renderCalendar({month:0, year:2007, renderCallback:testCallback});
    
     * 
    
     * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me. Every Thursday in the current month has a class of "thursday" applied to it, is clickable and shows an alert when clicked. Every Friday on the calendar has the number inside replaced with text.
    
     **/
    
     renderCalendar  :   function(s)
    
     {
    
     var dc = function(a)
    
     {
    
     return document.createElement(a);
    
     };
    
     s = $.extend({}, $.fn.datePicker.defaults, s);
    
     
    
     if (s.showHeader != $.dpConst.SHOW_HEADER_NONE) {
    
     var headRow = $(dc('tr'));
    
     for (var i=Date.firstDayOfWeek; i<Date.firstDayOfWeek+7; i++) {
    
     var weekday = i%7;
    
     var day = Date.dayNames[weekday];
    
     headRow.append(
    
     jQuery(dc('th')).attr({'scope':'col', 'abbr':day, 'title':day, 'class':(weekday == 0 || weekday == 6 ? 'weekend' : 'weekday')}).html(s.showHeader == $.dpConst.SHOW_HEADER_SHORT ? day.substr(0, 1) : day)
    
     );
    
     }
    
     };
    
     
    
     var calendarTable = $(dc('table'))
    
     .attr(
    
     {
    
     'cellspacing':2
    
     }
    
     )
    
     .addClass('jCalendar')
    
     .append(
    
     (s.showHeader != $.dpConst.SHOW_HEADER_NONE ? 
    
     $(dc('thead'))
    
     .append(headRow)
    2019-07-17 19:51:13
    赞同 展开评论
问答分类:
问答标签:
问答地址: