使用jQuery UI datepicker选择日历更改URL
我正在使用jQuery UI选择器,我想知道当有人选择日期时它是否可能,它会自动将它们重定向到URL,如下所示:
index.php?date=2013-10-15
这是我正在使用的插件。
$(function() { $( "#datepicker" ).datepicker(); });
Date:
1)您需要的是window.location.href
,它用于重定向页面。 您可以自定义打开窗口的方式。
2)在datepicker( onSelect
)中选择日期后,您可以将change
事件组合为@TJ Crowder在他的回答中说。
你可以这样试试
$("#datepicker") .datepicker({ dateFormat: "yy-mm-dd", onSelect: function(dateText) { $(this).change(); } }) .change(function() { window.location.href = "index.php?date=" + this.value; });
试试这个:
$(function () { $("#datepicker").datepicker({ dateFormat: "yy-mm-dd", onSelect: function () { window.open(document.URL + '?date=' + this.value); } }); });
在这里演示
我希望这可以按照您的要求进行。
日期:
Date: