简体   繁体   English

jQuery show()/ hide()选择器作为开始日期范围

[英]JQuery show()/hide() selector for start date range

Here is the fiddle. 是小提琴。 I am trying to allow the user to select a range (multiple times if they choose) and it show the positions within the time frame. 我试图允许用户选择一个范围(如果选择,则多次),它显示了时间范围内的位置。 I can not get the start date input range to work more than once, despite it being on change. 尽管开始日期输入范围有所更改,但我无法使其多次运行。 The start date selector code is this: 开始日期选择器代码是这样的:

//start selector functionality
    $('#startdate').on('change', function () {
        var $formelem = $(this);
        // Hide all positions that end before the specified date.
        $('section.position time.start').each(function () {
            if (compareTime($(this).attr('datetime'), $formelem.val()) <= 0) {
                $(this).parent().hide();
            } else {
                $(this).parent().show();
            }
        });
        $('section.company > time').remove();
        $('section.company').each(processCompanyTime);
    });

Any clues as to why it won't work more than once? 关于为什么它不能多次使用的任何线索? the end selector works multiple times. 结束选择器可以多次工作。

Your problem is in your processCompanyTime function which has a condition to hide the section.company but not to show it. 您的问题出在processCompanyTime函数中,该函数具有隐藏section.company而不显示它的条件。 So when it's hidden, it will never be shown again. 因此,当它被隐藏时,将不再显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM