简体   繁体   English

Select 元素在运行时不在 DOM 中 IntroJS

[英]Select elements not in DOM at runtime IntroJS

I'm using introJS to make a walkthrough for a third party web app, and can't figure out how to select an element that isn't in the DOM when the IntorJS script start running.我正在使用 introJS 为第三方 web 应用程序进行演练,并且无法弄清楚如何在 IntorJS 脚本开始运行时将 select 一个不在 DOM 中的元素。 There is a menu that pops out as an overlay div when you click a button.当您单击按钮时,会弹出一个菜单作为覆盖 div。 I can't seem to select any of its classes.我似乎无法 select 任何它的类。

In order to add an element to Intro.js steps, the element must exist and rendered in the browser.为了向 Intro.js 步骤添加元素,该元素必须存在并在浏览器中呈现。 One thing you can do though is using the CSS selectors and calling the refresh() method once your application is rendered.不过,您可以做的一件事是使用 CSS 选择器并在呈现应用程序后调用refresh()方法。

Example:例子:

 var intro = introJs();
          intro.setOptions({
            steps: [
              {
                element: '#step3',
                intro: 'More features, more fun.',
                position: 'left'
              },
              {
                element: '#step4',
                intro: "Another step.",
                position: 'bottom'
              },
              {
                element: '#step5',
                intro: 'Another Step'
              }
            ]
          });

          intro.start();

and then call intro.refresh() when your application is fully rendered .然后在您的应用程序完全呈现时调用intro.refresh() Once refersh() is called, Intro.js tried to re-evaluate all selectors and find the elements from the DOM.一旦refersh() ,Intro.js 就会尝试重新评估所有选择器并从 DOM 中查找元素。

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

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