JavaScript

一.下载功能

<html>

    <head>

        <meta charset="utf-8">

        <title></title>

        <link href="css/bootstrap.css" rel="stylesheet" />

        

        <script src="js/bootstrap.js"></script>

    </head>

    <body>

        

        <div class="progress" role="progressbar" aria-label="Example with label" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">

         <div id="a" class="progress-bar" style="width: 0%">0%</div>

        </div>

        

        <script>

         

            var i = 0;

            

            var div = document.getElementById("a");

            

            var aaa = setInterval(function(){

                i++;

                div.style.width = i + "%";

                div.innerText = i +"%";

                

                if (i==100) {

                    clearInterval(aaa);

                }

            },10000);

            

        </script>       

                

    </body>

</html>

二.数组的排序算法

<html>

    <head>

        <meta charset="utf-8">

        <title></title>

    </head>

    <body>

          

        <script>

            

            var a = [1,432,6,234,65,76,876,987];

            

            a.sort(function(a,b){

                return b-a; //倒序

            })

            console.log(a);

            

            a.sort(function(a,b){

                return a-b; //正序

            })

            console.log(a);

            

            a.sort(function(){

                return Math.random() - 0.5; //随机排列

            })

            

            console.log(a);

            

        </script>

        

    </body>

</html>

三.去除事件

<html>

    <head>

        <meta charset="utf-8">

        <title></title>

    </head>

    <body>

        <button>按钮</button>

        <button>取消按钮</button>

        <script>

            document.getElementsByTagName("button")[0].onclick = function(){

                alert(123);

            }

            

            document.getElementsByTagName("button")[1].onclick = function(){

                

                document.getElementsByTagName("button")[0].onclick = null;

                

            }

            

        </script>

    </body>

</html>

四.图片的移动

<html>

    <head>

        <meta charset="utf-8">

        <title></title>

        <style>

            img{

                /* margin-left: 300px; */

            }

        </style>

        

    </head>

    <body>

        <img src="img/1.gif" />

        

        <script>

            var img = document.getElementsByTagName("img")[0];

            var left_index = 0;

            setInterval(function(){

                left_index++;

                img.style.marginLeft = left_index + "px";

            },10);

            

        </script>

        

    </body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值