gpt4 book ai didi

javascript - Pickadate.js : how to render the widget via another element

转载 作者:行者123 更新时间:2023-11-30 10:27:56 25 4
gpt4 key购买 nike

默认 http://amsul.ca/pickadate.js/index.htm当用户单击输入时呈现小部件。

我创建了一个图标,我希望在用户单击它时显示小部件。我试过:

$('#my-icon').on('click', function(){
$("input.dateFormat").pickadate();
$("input.dateFormat").click(); // Tried also with trigger
});

但是日历不显示。

有办法吗?

最佳答案

我认为触发点击(公认的解决方案)不是解决此问题的正确方法。使用 pickadate.js 的第 3 版 API,此处概述了打开/关闭选项:http://amsul.ca/pickadate.js/api.htm#method-open-close

代码会是这样的:

var $input = $('.datepicker').pickadate();
var picker = $input.data('pickadate');
$('.calendarIcon').click( function( e ) {
// stop the click from bubbling
e.stopPropagation();
// prevent the default click action
e.preventDefault();
// open the date picker
picker.open();
});

关于javascript - Pickadate.js : how to render the widget via another element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18698698/

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