Before reading, you can also go to the Bootstrap3.0 getting started learning series navigation to view the http://www.cnblogs.com/aehyok/p/3404867.html
This article mainly describes the JavaScript plug-in-drop menu.
Case
The scroll listening plug-in can automatically update the corresponding navigation tag based on the position of the scroll bar. You can scroll through this page to see the changes in the left navigation bar.
First, you can test the code to see the effect.
Content => <! -- Bootstrap --> <link href = rel = media => <! -- [Lt IE]> <script src => </script> <! [Endif] --> <style type =>-</style> After running, you can see the effect under the content, that is, where the scroll bar scroll the mouse gear.
Usage 1 -- data attributes
To listen<body>
) But added to the Div above, you can see the code by yourself. Then add attributes to the divdata-spy="scroll"
You can easily add the scroll listening function for the top navigation bar. Then adddata-target
Attribute. The value of this attribute is in any Bootstrap..nav
The ID or class of the parent element of the component.
<div data-offset= = data-spy= data-target=></div>
The navigation link address must have a corresponding target.
The link address in the navigation bar must have the same ID value for the corresponding page element. For example,<a href="#home">home</a>
Must correspond<div id="home"></div>
.
Usage 2 -- use JavaScript
Start the scroll listener using JavaScript:
<script type=>).scrollspy({ target:</script>
Remove the data-target attribute of the div whose style class is scrollspy-example. In this way, you can switch the scroll wheel.
Method. scrollspy ('refresh ')
When using the rolling listening plug-in, you need to call this method whenever you add or delete page elements from the DOM in the page, as follows:
$( $spy = $().scrollspy(
However, it is useless for the moment.
Option
Options can be passed through the data attribute or JavaScript. For the data attribute, you need to put the option name indata-
For exampledata-offset=""
.
Event
<script type=>).on(</script>
Note: you must add a scroll bar to the content of the rolling listener, that is, you must add a style in advance.
<style type=>-</style>
Give the Div content a certain height.
After a long tangle, it is because there is no scroll bar for the content. Please remember this 1.1.
This article has been updated to the Bootstrap3.0 getting started learning series navigation http://www.cnblogs.com/aehyok/p/3404867.html