Javascript传参参考

可参考的细节:

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>定时器-移动</title>
  <script type="text/javascript" src="jquery-3.2.1.min.js"></script>
 </head>

<style>
 #div{width:100px;height:100px;background:red;position:absolute; top:100px;}
 
</style>
 <body>
  <div id="div"></div>
  <div id="div2"></div>
<script>
var a=0;
function move(obj,time){
    var t=setInterval(function(){
       a=a+1;
        if(a<=200 && a>=0){
            obj.css("left",a);
        }
        else{
            clearInterval(t);
        }
    },time)
}
move($("#div"),10);
move($("#div2"),500);

</script>


 </body>
</html>
move($("#div"),10);注意传参
posted @ 2018-04-16 10:54  xh_Blog  阅读(295)  评论(0编辑  收藏  举报