js 代码
- <script type="text/javascript">
-
-
<style type="text/css">
-
div.test {
-
width:400px;
-
margin:5px auto;
-
border:1px solid #ccc;
-
}
-
div.test strong {
-
font-size:16px;
-
background:#fff;
-
border-bottom:1px solid #aaa;
-
margin:0;
-
display:block;
-
padding:5px 0;
-
text-decoration:underline;
-
color:#059B9A;
-
cursor:pointer;
-
}
-
div.test p {
-
height:400px;
-
background:#f1f1f1;
-
margin:0;
-
}
-
-
</style>
-
-
<div class="test">
-
<a name="header_1" id="header_1"></a>
-
<strong onclick="javascript:scroller('header_4', 800);">header_1 --> header_4</strong>
-
<p></p>
-
</div>
-
-
<div class="test">
-
<a name="header_2" id="header_2"></a>
-
<strong onclick="javascript:scroller('header_5', 800);">header_2 --> header_5</strong>
-
<p></p>
-
</div>
-
-
<div class="test">
-
<a name="header_3" id="header_3"></a>
-
<strong onclick="javascript:scroller('header_6', 800);">header_3 --> header_6</strong>
-
<p></p>
-
</div>
-
-
<div class="test">
-
<a name="header_4" id="header_4"></a>
-
<strong onclick="javascript:scroller('header_7', 800);">header_4 --> header_7</strong>
-
<p></p>
-
</div>
-
-
<div class="test">
-
<a name="header_5" id="header_5"></a>
-
<strong onclick="javascript:scroller('header_3', 800);">header_5 --> header_3</strong>
-
<p></p>
-
</div>
-
-
<div class="test">
-
<a name="header_6" id="header_6"></a>
-
<strong onclick="javascript:scroller('header_2', 800);">header_6 --> header_2</strong>
-
<p></p>
-
</div>
-
-
<div class="test">
-
<a name="header_7" id="header_7"></a>
-
<strong onclick="javascript:scroller('header_1', 800);">header_7 --> header_1</strong>
-
<p></p>
-
</div>
-
调用方式:
Code:
scroller(el, duration)
el : 目标锚点 ID
duration : 持续时间,以毫秒为单位,越小越快