Intro.js 不跳过隐藏元素

Intro.js doesn't skip over hidden element

我已经使用 Intro.js 一周了,发现它不会跳过隐藏元素:

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
          };
        }
      }

还是不行。

有人知道真正的问题是什么吗?请帮忙

获取 currentElement.style.display 仅当您已声明内联样式时才有效。如果您通过 css 规则设置它,它将不起作用。

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

您的 jQuery 方法不起作用的原因是您的条件正在检查与您想要的相反的东西。如果您想跳过隐藏的元素,您需要在元素 可见时 continue

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

Here's a fiddle