gpt4 book ai didi

javascript - 使用 intro.js 在步骤中触发函数

转载 作者:行者123 更新时间:2023-11-30 11:10:35 26 4
gpt4 key购买 nike

我已经尝试了这里的步骤: Step with click functionality in intro.js

获取在步骤中触发的函数。我没有成功执行函数,但教程仍在运行。最终目标是让函数触发按钮点击。谢谢你的帮助。

<script type="text/javascript">
function startIntro(){
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "Welcome to the page!",
onchange: function(){
console.log("test");
},
onbeforechange: function() {
console.log("before");
}
},
{
element: '#step1',
intro: "You can start doing something by clicking the New Item button."
},
{
element: '.thefilter',
intro: "You can filter any of the stock items in the table by using the search fields ",
position: 'bottom'
}
]
});
intro.start();
}
</script>

<a href="javascript:void(0);" onclick="startIntro();"><img style="position:fixed;" src="help.png" /></a>

最佳答案

我错过了示例中的某些内容,这些内容为我提供了所需的指导。

这是更新后的代码。

TLDR;删除了步骤中的内联 onchange 并将其附加到 intro.start 之前。有效!

<script type="text/javascript">
function startIntro(){
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "Welcome to the page!"
},
{
element: '#step1',
intro: "You can start doing something by clicking the New Item button."
},
{
element: '.thefilter',
intro: "You can filter any of the stock items in the table by using the search fields ",
position: 'bottom'
}
]
});
intro.onbeforechange(function () {
if (this._currentStep === 2) {
console.log('what is happening')
return false;
}
});
intro.start();
}
</script>

<a href="javascript:void(0);" onclick="startIntro();"><img style="position:fixed;" src="help.png" /></a>

关于javascript - 使用 intro.js 在步骤中触发函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53891489/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com