gpt4 book ai didi

jquery - 使用 jQuery UI 日期选择器选择日历更改 URL

转载 作者:行者123 更新时间:2023-11-30 23:49:48 24 4
gpt4 key购买 nike

我正在使用 jQuery UI 选择器,我想知道当有人选择日期时是否有可能,它会自动将他们重定向到 URL,如下所示:

index.php?date=2013-10-15

这是我正在使用的插件。

<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>

Date: <input type="text" id="datepicker" />

最佳答案

1) 您需要的是window.location.href ,用于重定向页面。您可以自定义窗口的打开方式。

2) 在日期选择器 (onSelect) 中选择日期后,您可以将 change 事件组合为@T.J。克劳德在他的answer中说道.

你可以这样尝试

$("#datepicker")
.datepicker({
dateFormat: "yy-mm-dd",
onSelect: function(dateText) {
$(this).change();
}
})
.change(function() {
window.location.href = "index.php?date=" + this.value;
});

关于jquery - 使用 jQuery UI 日期选择器选择日历更改 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19374587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com