Giter Site home page Giter Site logo

lizhaoting / jquery_headindex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xxyangyoulin/jquery_headindex

0.0 1.0 0.0 138 KB

jQuery插件,自动生成文章目录索引,手风琴式折叠显示,自动定位当前位置。

License: BSD 3-Clause "New" or "Revised" License

CSS 0.51% JavaScript 90.05% HTML 9.44%

jquery_headindex's Introduction

jquery_headindex

jQuery插件,自动生成文章目录索引,手风琴式折叠显示,自动定位当前位置。

查看演示

怎么使用?

step 1. 导入jquery和jquery.headindex

<script src="./js/jquery.3.3.1.js"></script>
<script src="../jquery.headindex.min.js"></script>

setp2.

$(function () {
    $(document).headIndex({
                articleWrapSelector: '.article-wrap',//包裹文章的元素的选择器
                indexBoxSelector: '.index-box',//用来放目录索引的元素的选择器
            });
})

默认参数

defaultOptions = {
        articleWrapSelector: ".article-wrap",/*包裹文章的选择器*/
        indexBoxSelector: ".index-box",/*包裹目录索引的选择器*/
        scrollSelector: 'body,html',/*滑动元素的选择器*/
        scrollWrap: window,/*能够监听到scrollSelector滑动的选择器*/

        subItemBoxClass: "index-subItem-box",
        itemClass: "index-item",
        linkClass: "index-link",
        offset: 0,/*滑动偏移量 按需求进行偏移*/
}

某些布局下,滚动时位置不准确的问题
这个需要自己手动适配一下,重写方法:

offsetTop: function (elem) {
    

届时,offset可能失效。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.