比如点击一个图片,  里面的某个 div 内容就往下滚动一次。 这样的JS该怎么样写啊?O(∩_∩)O谢谢谢谢。

解决方案 »

  1.   

    给你写了个最简单的,参考一下吧
    <div style="width:100px;height:300px;background-color:red;overflow:hidden">
    <div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px">
    </div>
    </div>
    <input type="button" value="button" onclick="abc()">
    <script type="text/javascript">

    var i=0;
    var sd=2;
    var time;
    function abc()
    {
    time=setTimeout("abc()",10); if(i<50)
    {
    document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+2+"px";
    i=i+sd;
    }
    else
    {
    clearTimeout(time);
    i=0;
    }
    }
    </script>
      

  2.   

    document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+sd+"px";改一下
      

  3.   


    document.getElementById("a").style.marginTop=document.getElementById("a").
    style.marginTop.replace("px","")-0+sd+"px";改一下