gpt4 book ai didi

javascript - 单击日期选择器中的日期时重定向到新页面

转载 作者:行者123 更新时间:2023-11-30 17:07:33 24 4
gpt4 key购买 nike

我写了一个点击图片时打开日期选择器的代码:
这是屏幕截图:
img1
img2
这是代码:
HTML

<div style="position: absolute; top: 127px; left: 31px;">Click
on image to enter period start date:</div>

<img src='./img/calendar.png' id="datepickerImage"
style="position: absolute; top: 160px; left: 126px; height: 75px;" />

javascript

$(document).ready(function() {
$("#datepicker").datepicker({
changeMonth : true,
changeYear : true,
}).hide().click(function() {
$(this).hide();
});

$("#datepickerImage").click(function() {
$("#datepicker").show();
});

});

日期选择器打开成功。单击日期选择器上的任何日期时,我希望将其重定向到下一页。我该怎么做?

最佳答案

使用onSelect方法。

onSelect Type: Function() A callback function when a date is selected. The function receives the date text and date picker instance as parameters.

正如@Learner 在带有 fiddle 链接的评论中提到的那样。

并使用带有完整 url 的 window.location.href 进行重定向。

window.location.href= 'http://www.google.com'

关于javascript - 单击日期选择器中的日期时重定向到新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27683983/

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