jQuery中scrollLeft()方法用法实例

2020-05-23 06:09:14易采站长站整理

<style type=”text/css”>
#div1{
  border:1px solid black;
  width:200px;
  height:200px;
  overflow:auto
}
#div2{
  height:150px;
  width:400px;
}
#div3{
  height:40px;
  width:200px;
  background-color:green;
}
</style>
<script type=”text/javascript” src=”mytest/jQuery/jquery-1.8.3.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
  $(“button”).click(function(){
    $(“#div1”).scrollLeft(100);
  });
});
</script>
</head>
<body>
<div id=”div1″>
  <div id=”div2″>
    <div id=”div3″></div>
  </div>
</div>
<button>设置offset值</button>
</body>
</html>

希望本文所述对大家的jquery程序设计有所帮助。

本文转自:蚂蚁部落http://www.softwhy.com/