flee-lether
2016-05-29 11:12
采纳率: 100%
浏览 3.1k
已采纳

jqueryclearInterval怎么无法清除setInterval

<!--html-->
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>主站</title>
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <script src="lib/jquery-2.2.4.min.js" type="text/javascript"></script>
    <script src="lib/index.js" type="text/javascript"></script>
    <script type="text/javascript">
        var time1 = setInterval("lianimated1()", 0);
        var time2 = setInterval("lianimated2()", 0);
        $(function () {
            time1=cleananimated(time1,"ul.content_box_ul");
            time2=cleananimated(time2,"ul.visit_box_ul");
        });
    </script>
</head>

<body>
<!--------------------header---------------------->
<div id="header"><img src="images/header.jpg"></div>
<!----------------------nav----------------------->
<div id="nav">
    <ul>
        <li id="current_page"><a href="index.html">首页</a></li>
        <li><a href="introduce.html">个人简介</a></li>
        <li><a href="photolist.html">个人相册</a></li>
        <li><a href="articlelist.html">日志</a></li>
        <li><a href="careerlist.html">职业规划</a></li>
        <li><a href="worklist.html">作品展示</a></li>
    </ul>
</div>
<!--------------------content--------------------->
<div id="content">
    <div id="left_nav">
        <ul>
            <li><span><a class="title" href="index.html">首页</a></span></li>
            <li><span><a class="title" href="photolist.html">相册列表</a></span></li>
            <li><a href="sceneryphoto.html">旅游相册</a></li>
            <li><a href="cartoonphoto.html">动漫卡通</a></li>
            <li><a href="studyphoto.html">大学时光</a></li>
            <li><span><a class="title" href="careerlist.html">职业规划</a></span></li>
            <li><a href="#">大学生活</a></li>
            <li><a href="#">活动参与</a></li>
            <li><a href="#">实习打算</a></li>
            <li><span><a class="title" href="articlelist.html">我的日志</a></span></li>
            <li><a href="#">星湖游记</a></li>
            <li><a href="#">重庆一览</a></li>
            <li><a href="#">荷塘月色</a></li>
            <li><span><a class="title" href="introduce.html">个人简历</a></span></li>
            <li><a href="#">姓名</a></li>
            <li><a href="#">姓别</a></li>
            <li><a href="#">工作经验</a></li>
            <li><span><a class="title" href="worklist.html">作品展示</a></span></li>
            <li><a href="#">ps作品</a></li>
            <li><a href="#">HTML作品</a></li>
            <li><span><a class="title" href="#">经典瞬间</a></span></li>
        </ul>
    </div>
    <div id="right_content">
        <div id="photo">
            <ul>
                <li><a href="#"><img src="images/one.jpg"></a></li>
                <li><a href="#"><img src="images/two.jpg"></a></li>
                <li><a href="#"><img src="images/three.jpg"></a></li>
                <li><a href="#"><img src="images/four.jpg"></a></li>
            </ul>
        </div>
        <div id="title">
            <div id="acedemic_image"><a href="#"><img src="images/more.png"></a>日志动态</div>
            <div class="content_box">
                <ul class="content_box_ul">
                    <li><a href="#">我很不幸的过了英语四级啊</a><span>06-13</span></li>
                    <li><a href="#">一女生说:生命科学院院长演讲一场,彻...</a><span>04-13</span></li>
                    <li><a href="#">【转】班任为王,导员为皇,讲师为妃,...</a><span>03-11</span></li>
                    <li><a href="#">一,当你发现自己不再盲目的喜欢跟风似...</a><span>02-19</span></li>
                    <li><a href="#">很多人都认为节省能让他们的生活更保险...</a><span>02-10</span></li>
                    <li><a href="#">请不要随意的对一个人下定义告诉你这样...</a><span>02-09</span></li>
                    <li><a href="#">【转】我现在终于明白,其实爱情没那么...</a><span>02-01</span></li>
                    <li><a href="#">请不要随意的对一个人下定义告诉你这样...</a><span>01-19</span></li>
                    <li><a href="#">我很不幸的过了英语四级啊</a><span>06-13</span></li>
                    <li><a href="#">一女生说:生命科学院院长演讲一场,彻...</a><span>04-13</span></li>
                    <li><a href="#">【转】班任为王,导员为皇,讲师为妃,...</a><span>03-11</span></li>
                    <li><a href="#">一,当你发现自己不再盲目的喜欢跟风似...</a><span>02-19</span></li>
                    <li><a href="#">很多人都认为节省能让他们的生活更保险...</a><span>02-10</span></li>
                    <li><a href="#">请不要随意的对一个人下定义告诉你这样...</a><span>02-09</span></li>
                    <li><a href="#">【转】我现在终于明白,其实爱情没那么...</a><span>02-01</span></li>
                    <li><a href="#">请不要随意的对一个人下定义告诉你这样...</a><span>01-19</span></li>
                </ul>
            </div>
        </div>
        <div id="text">
            <div class="box">
                <div id="introduce">
                    <h3>个人简介</h3>
                    <p>我叫,<br>
                        来自。</p>
                </div>
            </div>
            <div class="box">
                <div id="career">
                    <h3>职业</h3>
                    <p>现学习软件工程,<br>
                        想从事软件开发。</p>
                </div>
            </div>
            <div class="box">
                <div id="love">
                    <h3>个人爱好</h3>
                    <p>喜欢古典文学,<br>
                        喜欢乒乓球。</p>
                </div>
            </div>
        </div>
        <div id="visit">
            <div id="visit_image"><a href="#"><img src="images/more.png"></a>最近发生</div>
            <div class="visit_box">
                <ul class="visit_box_ul">
                    <li><a href="#">爬高压线触电身亡&nbsp;身体被烧焦浓烟滚滚恐怖</a><span>06-20</span></li>
                    <li><a href="#">抗日雷剧再现神技:自行车飞拦火车似直升机</a><span>06-19</span></li>
                    <li><a href="#">成龙动作电影周落幕《战狼》豪取四奖成最大赢家</a><span>06-18</span></li>
                    <li><a href="#">爬高压线触电身亡&nbsp;身体被烧焦浓烟滚滚恐怖</a><span>06-20</span></li>
                    <li><a href="#">抗日雷剧再现神技:自行车飞拦火车似直升机</a><span>06-19</span></li>
                    <li><a href="#">成龙动作电影周落幕《战狼》豪取四奖成最大赢家</a><span>06-18</span></li>
                    <li><a href="#">爬高压线触电身亡&nbsp;身体被烧焦浓烟滚滚恐怖</a><span>06-20</span></li>
                    <li><a href="#">抗日雷剧再现神技:自行车飞拦火车似直升机</a><span>06-19</span></li>
                    <li><a href="#">成龙动作电影周落幕《战狼》豪取四奖成最大赢家</a><span>06-18</span></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!--------------------footer---------------------->
<div id="footer">
</div>
</body>
</html>

 <!--js-->
 var len1=0;
function lianimated1() {
    var $right_content=$("#right_content");
    var $box=$right_content.find("div.content_box");
    var $box_ul=$right_content.find("ul.content_box_ul");
    var height=$box.height();
    var ul_height=$box_ul.height();
    if(len1<(ul_height-height)){
        $box_ul.animate({marginTop: '-=' +10},"slow");
        len1+=10;
    }else{
        $box_ul.animate({marginTop: '+=' +len1},0);
        len1=0;
    }
}
var len2=0;
function lianimated2() {
    var $right_content=$("#right_content");
    var $box=$right_content.find("div.visit_box");
    var $box_ul=$right_content.find("ul.visit_box_ul");
    var height=$box.height();
    var ul_height=$box_ul.height();
    if(len2<(ul_height-height-60)){
        $box_ul.animate({marginTop: '-=' +10},"slow");
        len2+=10;
    }else{
        $box_ul.animate({marginTop: '+=' +len2},0);
        len2=0;
    }
}
function cleananimated(time,a) {
    var $right_content=$("#right_content");
    var $box_ul=$right_content.find(a);
    $box_ul.mouseover(function () {
        clearInterval(time);
    }).mouseout(function () {
        time1=setInterval("lianimated1()",50);
        return time1;
    });
}

2条回答 默认 最新

相关推荐 更多相似问题