这是我第一次使用jQuery UI,并且我的JS技能是初学者。
我有什么问题:
我想使用JQuery UI datepicker进行选择:
如何获取日期/日期范围?但是,得到一个简单的工作示例将是很好的。
也许这样的事情可以帮助您:
$( "#datepicker" ).datepicker({
showWeek: true,
firstDay: 1
});
// Highlight week on hover week number
$(document).on("mouseenter",".ui-datepicker-week-col",
function(){$(this).siblings().find("a").addClass('ui-state-hover');} );
$(document).on("mouseleave",".ui-datepicker-week-col",
function(){$(this).siblings().find("a").removeClass('ui-state-hover');} );
// Select week on click on week number
$(document).on("click",".ui-datepicker-week-col",
function(){
$first = $(this).siblings().find("a").first();
$last = $(this).siblings().find("a").last();
$first.click();
$parentFirst = $first.parent();
$parentLast = $last.parent();
$("#datepicker").val(
(Number($parentFirst.data("month"))+1)+"/"+$first.text()+"/"+$parentFirst.data("year")
+ " - " +
(Number($parentLast.data("month"))+1)+"/"+$last.text()+"/"+$parentLast.data("year")
);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句