运动学JS

var myDate = new Date();
myDate.getYear();        //获取当前年份(2位)
myDate.getFullYear();    //获取完整的年份(4位,1970-????)
myDate.getMonth();       //获取当前月份(0-11,0代表1月)
myDate.getDate();        //获取当前日(1-31)
myDate.getDay();         //获取当前星期X(0-6,0代表星期天)
myDate.getTime();        //获取当前时间(从1970.1.1开始的毫秒数)
myDate.getHours();       //获取当前小时数(0-23)
myDate.getMinutes();     //获取当前分钟数(0-59)
myDate.getSeconds();     //获取当前秒数(0-59)
myDate.getMilliseconds();    //获取当前毫秒数(0-999)
myDate.toLocaleDateString();     //获取当前日期
var mytime=myDate.toLocaleTimeString();     //获取当前时间
myDate.toLocaleString( );        //获取日期与时间

谈到JS,大家都会想到是让物体动起来!没错,究竟是怎么动的,!

             setTimeout(function(){,30);  定时器走一次

定时器    setInterval(function(){},30);  定时器循环

清除定时器    clearInterval(); 

向上取整   math.ceil(4.5);  //  5

向下取整   math.floor(5.9);  // 5

四舍五入   math.round(1.2);   // 1

                math.round(1.51);   // 2

转化为整形   parseInt("123",8)   //1*8e2+2*8e1+3  =83  

转化为浮点型   parseFloat()   

odiv.style.width=220px;  //这个只适合用于提取行间样式

getStyle()            //获取非行间样式

function getStyle(obj, attr)
{
 if(obj.currentStyle)
 {
  return obj.currentStyle[attr];
 }
 else
 {
  return getComputedStyle(obj, false)[attr];
 }
}

对象的可见宽度   offsetWidth = width + padding + border

var  speed=(itarget-offsetWidth)/6

ps:多物体运动,需要注意多个物体都要有定时器!

       多物体运动,所有的东西都不能共用!

       如需要共用,需以变量的形式存在与运动对象绑定!


二级联动

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>ceshi</title>

</head>

<body>

<script>

    var arr=['请选择','省1','省2','省3','省4'];

    var app=[ 

             [],

             ['省1A','省1B','省1C','省1D'],

             ['省2A','省2B','省2C','省2D'],

             ['省3A','省3B','省3C','省3D'],

             ['省4A','省4B','省4C','省4D'],

    ];

      window.onload=function (){

        creatcity();

        document.getElementById('city1').onchange=creatcity2;

   }

        function creatcity(){

        city1=document.getElementById('city1');

             for(var i in arr){

                 var op=new Option(arr[i],arr[i]);

                 city1.options.add(op);

              }    

       }

       function creatcity2(){

        var index=document.getElementById('city1').selectedIndex;

            city2=document.getElementById('city2');

            city2.options.length=0;

        //alert(index);

          for(var i in app){

              var op1=new Option(app[index][i],app[index][i]);

              city2.options.add(op1);

           }

       }

</script>

      <select name="" id="city1"></select>

      <select name="" id="city2"></select>

</body>

</html>




转载于:https://my.oschina.net/u/2611640/blog/604235

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值