首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >隐藏jQuery数据采集器

隐藏jQuery数据采集器
EN

Stack Overflow用户
提问于 2013-11-23 13:59:47
回答 2查看 2.3K关注 0票数 0

我希望在单击一个小图像时呈现一个数据报警器,选择日期,使用所选日期填充一组基于所选日期的年份、月份和天数的选择元素。我计算出了onSelect部分,并将所选日期应用到select元素中的选项中。

我的问题是数据报警器没有关闭日期选择。它就呆在那里。如果我调用hide()方法,它也会隐藏图像( span元素的一部分)。这是我的HTML代码:

代码语言:javascript
复制
<span id="pickupCalendar"><img src="/images/calendar.png"></img></span>

这是一个脚本:

代码语言:javascript
复制
$("#pickupCalendar").click(function () {
    $("#pickupCalendar").datepicker({
        dateFormat: 'dd-mm-yy',
        onSelect: function (dateText, inst) {
            //code to fill the other elements with the selected date goes here
            $("#pickupCalendar").datepicker().hide(); //<-- hides the image (span element along with the datepicker)
        }
    });
});
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-11-23 14:35:29

我会更改HTML标记,这样就可以更容易地将元素作为目标。

代码语言:javascript
复制
<span id="pickupCalendar"></span><button>Button</button>

    $("button").click(function () {
        $("#pickupCalendar").show();
        $("#pickupCalendar").datepicker({
            dateFormat: 'dd-mm-yy',
            onSelect: function (dateText, inst) {
               //code to fill the other elements with the selected date goes here
               $("#pickupCalendar").datepicker().hide(); 
            }
        });
    });

小提琴

票数 1
EN

Stack Overflow用户

发布于 2013-11-23 14:09:02

你能试试这个吗?

代码语言:javascript
复制
$("#pickupCalendar").click(function () {
    $("#pickupCalendar").datepicker({
        dateFormat: 'dd-mm-yy',
        onSelect: function (dateText, inst) {
            //code to fill the other elements with the selected date goes here
            $("#pickupCalendar").datepicker().hide(); 
            $("#pickupCalendar img").hide();
        }
    });
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20163224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档