<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>任意屬性值(一)</title>
</head>
<style>
????*{margin:?0;padding:?0}
????ul?li{
????????list-style:?none;
????}
????li{
????????width:?200px;
????????height:?100px;
????????background:?yellow;
????????margin-bottom:?10px;
????????border:?5px?solid?#000;
????}
</style>
<script>
????window.onload=function(){
????????var?Li1=document.getElementById("li1");
????????var?Li2=document.getElementById("li2");
????????Li1.onmouseover=function(){
????????????startMove(this,"height",400);
????????}
????????Li1.onmouseout=function(){
????????????startMove(this,"height",100);
????????}
????????Li2.onmouseover=function(){
????????????startMove(this,"width",400);
????????}
????????Li2.onmouseout=function(){
????????????startMove(this,"width",200);
????????}
????}
????function?getStyle(obj,attr){
????????if(obj.currentStyle){
????????????return?obj.currentStyle[attr];
????????}
????????else{
????????????return?getComputedStyle(obj,false)[attr];
????????}
????}
????function?startMove(obj,attr,iTarget){
????????clearInterval(obj.timer);
????????obj.timer=setInterval(function(){
????????????var?icur=parseInt(getStyle(obj.attr));
????????????var?speed=(iTarget-icur)/8;
????????????speed=speed>0?Math.ceil(speed):Math.floor(speed);
????????????if(icur==iTarget){
????????????????clearInterval(obj.timer);
????????????}
????????????else{
????????????????obj.style[attr]=icur+speed+"px";
????????????}
????????},30);
????}
</script>
<body>
<ul>
????<li?id="li1"></li>
????<li?id="li2"></li>
</ul>
</body>
</html>
2017-03-01
我自己找到了 第48行應(yīng)該是逗號