麻烦看一下我哪里写错了...注释掉的部分就是自己写的运动<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style> div { width: 100px; height: 100px; background-color:pink; margin: 10px; float: left; border: 10px solid #000; font-size: 16px; } </style> <script src="move.js"></script> <script> window.onload=function() { var div1=document.getElementById("div1"); var div2=document.getElementById("div2"); var div3=document.getElementById("div3"); div1.onmouseover=function () { yundong(this,'height',500); } div1.onmouseout=function () { yundong(this,'height',100); } div2.onmouseover=function () { yundong(this,"width",500); } div2.onmouseout=function () { yundong(this,"width",100); } div3.onmouseover=function () { yundong(this,"fontSize",50); } div3.onmouseout=function () { yundong(this,"fontSize",10); } }//// function getStyle(obj,name)// {// if(obj.currentStyle)// {// return obj.currentStyle[name]// }// else// {// return getComputedStyle(obj,false)[name];// }// }//// function yundong(obj,bb,mubiao)// {//// clearInterval(obj.timer);// obj.timer=setInterval(function()// {// var cur=parseInt(getStyle(obj,bb));// sudu=(mubiao-cur)/6;// sudu=sudu>0?Math.ceil(sudu):Math.floor(sudu);// if(cur==mubiao)// {// clearInterval(obj.timer)// }// else// {// obj.style[bb]=cur+sudu+"px";// }// },30)// } </script></head><body><div id="div1">变高</div><div id="div2">变宽</div><div id="div3">dasf</div></body></html>
添加回答
举报
0/150
提交
取消