【问题标题】:IntroJs Hints if parent not Visible如果父级不可见,则 IntroJs 提示
【发布时间】:2021-11-19 18:45:11
【问题描述】:

IntroJs 提示 当父元素不可见时如何跳过或隐藏?出于某种原因,似乎只有内联对我的提示起作用。我在 HTML 的跨度中有数据提示,我需要检查最近的元素是否可见或父/子元素。

var hints = false;

var all = document.getElementsByTagName("*");

函数 introFunction() {

for (var i = 0, max = all.length; i < max; i++) {
    if ((isHidden(all[i]) && hints));
    document.getElementById("#helpFunc").html("Show Help");
    introJs().hideHints();
} else {
    document.getElementById("#helpFunc").html("Hide Help");
    introJs().showHints();
}
hints = !hints;

function isHidden(el) {
    var style = window.getComputedStyle(el);
    return ((style.display === 'none') || (style.visibility === 'hidden'));
}

}

【问题讨论】:

    标签: if-statement show-hide visible intro.js hints


    【解决方案1】:

    不要尝试获取元素的计算样式,而是尝试检查元素边界矩形 - 如果没有,则表示该元素不可见。

    !!el.getClientRects().length; // false means el or its parent(s) is hidden
    

    LE:这不适用于“可见性:隐藏;”尽管。所以也许你可以把上面的和你已经拥有的结合起来。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-19
      • 1970-01-01
      • 2020-12-09
      • 2011-12-14
      • 1970-01-01
      • 2017-07-04
      • 2014-05-02
      • 1970-01-01
      相关资源
      最近更新 更多