dsen53898 2016-06-29 08:37
浏览 144
已采纳

Intro.js不会跳过隐藏的元素

I been working with Intro.js for a week now and found out that it doesn't skip over hidden elements:

for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) {
        var currentElement = allIntroSteps[i];

        //alert(( jQuery(currentElement).is(':visible') ));
        // skip hidden elements
        /*if (jQuery(currentElement).is(':visible') == true) {
          continue;
        }*/

        if (currentElement.style.display == 'none') {
          continue;
        }

        var step = parseInt(currentElement.getAttribute('data-step'), 10);

        if (step > 0) {
          introItems[step - 1] = {
            element: currentElement,
            intro: currentElement.getAttribute('data-intro'),
            step: parseInt(currentElement.getAttribute('data-step'), 10),
            tooltipClass: currentElement.getAttribute('data-tooltipClass'),
            highlightClass: currentElement.getAttribute('data-highlightClass'),
            position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
          };
        }
      }

it still doesn't work.

anyone know what is the real issue ? please help

  • 写回答

1条回答 默认 最新

  • douke6857 2016-06-29 09:26
    关注

    Getting currentElement.style.display will only work if you've declared the style inline. It won't work if you're setting it via a css rule.

    <div style="display: none;"> // el.style.display = 'none'
    <div class="ruleWithDisplayNone"> // el.style.display = ''
    

    The reason your jQuery approach won't work is because your condition is checking the opposite of what you want. If you want to skip over hidden elements, you want to continue when the element isn't visible.

    if (! jQuery(currentElement).is(':visible')) {
        continue;
    }
    

    Here's a fiddle

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等