下拉菜单

 <script>
        var timer1 = null;
        var oDiv1 = document.getElementById("div1");

        Move(oDiv1, timer1);

        var timer2 = null;
        var oDiv3 = document.getElementById("div3");
        Move(oDiv3, timer2);


        function Move(oDiv, timer) {

            oDiv.onmouseover = function () {
                if (oDiv.offsetHeight < 390) {
                    clearInterval(timer);
                    timer = window.setInterval(function () {

                        oDiv.style.height = (oDiv.offsetHeight + 10) + 'px';

                        if (oDiv.offsetHeight >= 400) {
                            clearInterval(timer);
                        }

                    }, 20);
                }
            };

            oDiv.onmouseout = function () {

                if (oDiv.offsetHeight > 50) {
                    clearInterval(timer);
                    timer = window.setInterval(function () {

                        oDiv.style.height = (oDiv.offsetHeight - 10) + 'px';
                        if (oDiv.offsetHeight <= 50) {
                            clearInterval(timer);
                        }

                    }, 20);
                }
            };
        }

    </script>

  

posted @ 2016-07-04 20:34  宋小尧  阅读(79)  评论(0编辑  收藏  举报