日期:2014-05-16 浏览次数:20495 次
_x=Math.abs(dog_left-box_left); _y=Math.abs(dog_top-box_top); if(obj.value=="上" && !(_y==0)) { dog.style.top=(dog_top-10)+"px"; dog_top=dog_top-10; }else if(obj.value=="下" && !(_y==(box_height-dog_height)))//这里要越界 { dog.style.top=(dog_top+10)+"px"; dog_top=dog_top+10; }else if(obj.value=="左" && !(_x==0)) { dog.style.left=(dog_left-10)+"px"; dog_left=dog_left-10; }else if(obj.value=="右" && !(_x==(box.width-dog_width)))//这里要越界 { dog.style.left=(dog_left+10)+"px"; dog_left=dog_left+10; }