GithubHelp home page GithubHelp logo

wordpressdev / jquery.arbitrary-anchor.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from briangonzalez/jquery.arbitrary-anchor.js

0.0 2.0 0.0 78 KB

Arbitrary anchors for any element on your page using a little jQuery magic.

jquery.arbitrary-anchor.js's Introduction

jquery.arbitrary-anchor.js

This plugin allows the page to scroll to any arbitrary object on the page based on jQuery/CSS selector.

Visit us on the web or follow me on Twitter for updates: @brianmgonzalez.

Usage

Usage is simple. Just drop it into your page's head after jQuery. Then it just works.

Add to your page:

  <script type="text/javascript" src="jquery.arbitrary-anchor.js"></script>

Use:

Then you can add any valid jQuery/CSS selector after the hash (#) in your page's URL, and it will automatically be scrolled to. If the selector returns more than 1 element, the first element found will be scrolled to. You can also place a pipe (|) with a value in milliseconds after the selector to change the time it takes to scroll to the given element, e.g. #.mydiv|200 would scroll to the first element with a class of mydiv and it would scroll to it in 200ms.

Example URLs

URL Scrolls To
http://example.com#raptor element with ID of or anchor with name of raptor
http://example.com#p element with ID of or anchor with name of raptor, if none, scroll to first <p>
http://example.com##yo-man first element with ID of yo-man
http://example.com#.brah first element with class of brah
http://example.com#.sup.brah first element with class of sup and brah
http://example.com#.sup.brah|100 first element with class of sup and brah, scrolled to in 100ms (default is 750ms)
http://example.com#footer element with ID of or anchor with name of footer, or first footer
http://example.com#footer|200 same as above, scrolled to in 200ms

On the web

Visit us at http://briangonzalez.org/arbitrary-anchor

jquery.arbitrary-anchor.js's People

Contributors

briangonzalez avatar

Watchers

James Cloos avatar Rafique avatar

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.