首页 > 代码库 > 点击文字使其滚动到中间位置,有滚动效果

点击文字使其滚动到中间位置,有滚动效果

 

<html>
<head>
<title>abc</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

</head>
<script language="JavaScript" src="http://www.mamicode.com/jquery.js" type=""></script>

<script type="text/javascript">

  var q=document.getElementById("choice");
  box.innerHTML+=box.innerHTML;

  

function a(obj){
q.scrollTop=45;  //根据自己的div调整 scrollTop的大小
}
function b(obj){
q.scrollTop=61;
}
function c(obj){
q.scrollTop=79;
}
function d(obj){
q.scrollTop=13;
}
function ee(obj){
q.scrollTop=30;
}
</script>

<body>

<div id="choice" style="z-index:20;margin-top: 25px;height:80px;overflow:hidden;">
  <a id="a" href="javascript:" onclick="a(this)">111</a>
  <a id="b" href="javascript:" onclick="b(this)">222</a>
  <a id="c" href="javascript:" onclick="c(this)">333</a>
  <a id="d" href="javascript:" onclick="d(this)">444</a>
  <a id="e" href="javascript:" onclick="ee(this)">555</a>
</div>

</body>
</html>

 

点击文字使其滚动到中间位置,有滚动效果