Js用户引导插件intro

1.demo直接贴上来了,有什么不懂的,直接去官网上看,地址:https://introjs.com/。

2.这个intro插件的版本是v2.7.0,复制下来代码,引入库应该直接可以运行。

3.点评一下:
  a.插件不会自己记录引导的信息,需要手动控制引导是不是执行过
  b.不在step里提供钩子,而是提供全局的钩子
  c.在全局钩子里用this._introItems[this._currentStep]找到当前的
  d.可以在step里定义自己的函数,然后在全局钩子里调用
  e.不能动态生成节点
  f.backdrop的时候,点下一步不会闪
  g.提供hints的支持
  h.element为id的时候没啥说的,为class的时候,第一个匹配上的class出现引导

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="introjs.css" type="text/css" rel="stylesheet" />
<script src="jquery-2.1.4.js"></script>
<script type="text/javascript"  src="intro.js"></script>
<script type="text/javascript">
    $(function(){
        intro = introJs();
        intro.setOptions({
            
            prevLabel:"<", 
            nextLabel:">",
            skipLabel:"skip",
            doneLabel:"done",
            
            steps: [
                {    
                    element: '#div1',
                    intro: '1~~',
                    position: 'right'
                },
                {
                    element: '#div2',
                    intro: '2~~',
                    position: 'right'
                },
                {
                    element: '.div3',
                    intro: '<a href="www.cnblogs.com">3</a>~~',
                    position: 'bottom'
                } 
            ],
            hints: [
                {
                    element: '#div1',
                    hint: "This is a tooltip.",
                    hintPosition: 'top-middle'
                },
                {
                    element: '#div2',
                    hint: 'More features, more fun.',
                    position: 'left'
                },
                {
                    element: '.div3',
                    hint: "<b>Another</b> step.",
                    hintPosition: 'top-middle'
                }
            ]

        });
        intro.onbeforechange(function(targetElement) {
           console.log(this)  // this._introItems[this._currentStep]
        });
        
        intro.start();
    });
</script>
</head>
<body>
    <div id="div1" style="width:150px;height:50px;">1</div>
    <div id="div2" style="width:150px;height:50px;">2</div>
    <div class="div3" style="width:150px;height:50px;">3</div>
    
    <button οnclick="intro.addHints()">addHint</button>
     
</body>
</html>

 

转载于:https://www.cnblogs.com/413xiaol/p/7912588.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个使用 Intro.js 生成引导页面的示例代码。这个示例中,我们将介绍如何创建一个简单的引导页面,并使用一些样式来美化它: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Intro.js 示例</title> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/intro.js/3.3.1/introjs.min.css"> <style> .introjs-tooltip { max-width: 400px; border-radius: 3px; box-shadow: 0 0 20px rgba(0,0,0,0.3); background-color: #fff; color: #333; } .introjs-arrow { border-top-color: #fff; } .introjs-tooltipbuttons { text-align: center; } .introjs-button { background-color: #e1e1e1; color: #333; border-radius: 3px; padding: 5px 10px; margin: 5px; cursor: pointer; } .introjs-button:hover { background-color: #d2d2d2; } .introjs-button:focus { outline: none; } </style> </head> <body> <h1>Intro.js 示例</h1> <p>这是一个使用 Intro.js 创建的引导页面示例。</p> <button id="startBtn">开始引导</button> <script src="https://cdnjs.cloudflare.com/ajax/libs/intro.js/3.3.1/intro.min.js"></script> <script> document.getElementById("startBtn").addEventListener("click", function() { introJs().setOptions({ steps: [ { element: document.querySelector('h1'), intro: "这是页面的标题。" }, { element: document.querySelector('p'), intro: "这是页面的主体内容。" }, { element: document.querySelector('#startBtn'), intro: "这是开始引导按钮。", position: 'bottom' } ], showBullets: false, exitOnOverlayClick: false, exitOnEsc: false }).start(); }); </script> </body> </html> ``` 在这个示例中,我们使用了一些 CSS 样式来美化 Intro.js 的工具提示框和按钮。我们还使用了 `setOptions()` 方法来设置引导页面的参数选项,例如 `steps`、`showBullets`、`exitOnOverlayClick` 和 `exitOnEsc` 等。最后,我们在按钮的点击事件中调用 `introJs().start()` 方法启动引导页面。 你可以根据自己的需求调整这个示例代码,以生成自己的引导页面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值