A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 滚去学习 初级黑马   /  2019-9-19 16:42  /  700 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>jquery</title>
    <script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>

    <script>
        $(function () {

            $("#startID").prop("disabled",false);
            $("#stopID").prop("disabled",true);

            //存取图片数组
            var imgs = [
                "../img/man00.jpg",
                "../img/man01.jpg",
                "../img/man02.jpg",
                "../img/man03.jpg",
                "../img/man04.jpg",
                "../img/man05.jpg",
                "../img/man06.jpg"
            ];

            var start;
            var index;
            //开始按钮
            $("#startID").click(function () {
                alert("开始")

                $("#startID").prop("disabled",true);
                $("#stopID").prop("disabled",false);


                start = setInterval(function () {
                    index = Math.floor(Math.random()*7);
                    $("#img1ID").prop("src",imgs[index]);
                },20);
            })

            //结束按钮
            $("#stopID").click(function () {

                $("#startID").prop("disabled",false);
                $("#stopID").prop("disabled",true);

                clearInterval(start);
                $("#img2ID").prop("src",imgs[index]).hide();

                $("#img2ID").show(1000);
            })
        })
    </script>

</head>
<body>

<!-- 小像框 -->
<div style="border-style:dotted;width:160px;height:100px">
    <img id="img1ID" src="../img/man02.jpg" style="width:160px;height:100px"/>
</div>

<!-- 大像框 -->
<div
        style="border-style:double;width:800px;height:500px;position:absolute;left:500px;top:10px">
    <img id="img2ID" src="../img/man00.jpg" width="800px" height="500px"/>
</div>

<!-- 开始按钮 -->
<input
        id="startID"
        type="button"
        value="点击开始"
        style="width:150px;height:150px;font-size:22px"
        onclick="imgStart()">

<!-- 停止按钮 -->
<input
        id="stopID"
        type="button"
        value="点击停止"
        style="width:150px;height:150px;font-size:22px"
        onclick="imgStop()">


<script language='javascript' type='text/javascript'>
    //准备一个一维数组,装用户的像片路径


</script>
</body>
</html>

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马