社区
JavaScript
帖子详情
菜鸟提问!!求算法!已知a,b,现在点鼠标a会向b游动,鼠标停,a会停下来
Nicholasqpl
2007-05-28 04:18:12
谢谢
...全文
507
11
打赏
收藏
菜鸟提问!!求算法!已知a,b,现在点鼠标a会向b游动,鼠标停,a会停下来
谢谢
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
liudongyue1987
2010-04-14
打赏
举报
回复
upupupupupup
xujorn
2010-04-05
打赏
举报
回复
厉害顶
cymple
2007-05-29
打赏
举报
回复
帮顶
btbtd
2007-05-28
打赏
举报
回复
哈哈, 我想弄个可以这样的...
<style type="text/css">
/* <![CDATA[ */
.MainTbl
{
margin:5px 0px;
}
.MainTbl tr td
{
padding:2px;
}
.MainTblTitle
{
background-color:#F2F2F2;
text-align:center;
padding:5px 0px;
}
.SolidBorder
{
background-color:#FFFFFF !important; /*表格背景色绝对白色*/
border-collapse: collapse; /*清除 IE 的默认边框*/
border: 1px solid #999999;
}
.TblSolidBorder
{
background-color:#FFFFFF !important; /*表格背景色绝对白色*/
border-collapse: collapse; /*清除 IE 的默认边框*/
border: 1px solid #999999;
}
.TblSolidBorder tr td
{
padding:2px!important;
}
.TblSolidBorder td, .TblSolidBorder th
{
border-top: 1px solid #999999; /* 设置 1px 比设置为 thin 通用 */
border-right: 1px solid #999999;
border-collapse: collapse; /*清除 IE 默认边框*/
padding:2px;
}
.Area
{
width:40px;
height:40px;
}
/* ]]> */
</style>
<table border="0" cellspacing="0" cellpadding="0" class="MainTbl TblSolidBorder" align="center">
<tr>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="LeftTopId">LeftTopId</div>
</td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="CenterTopId">CenterTopId</div>
</td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="RightTopId">RightTopId</div>
</td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
<tr>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="LeftMiddleId">LeftMiddleId</div>
</td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="AxisId" class="Area TblSolidBorder">AxisId</div>
</td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="RightMiddleId">RightMiddleId</div>
</td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
<tr>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="LeftBottomId">LeftBottomId</div>
</td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="CenterBottomId">CenterBottomId</div>
</td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td colspan="2" rowspan="2" align="center" valign="middle">
<div id="RightBottomId">RightBottomId</div>
</td>
</tr>
<tr>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
<td width="50" height="50"> </td>
</tr>
</table>
btbtd
2007-05-28
打赏
举报
回复
呵呵, 楼上好强....
要我的话起码得预先知道这些:
a.x, a.y, a.width, a.height
b.x, b.y, b.width, b.height
chouchy
2007-05-28
打赏
举报
回复
<script language="JavaScript">
<!--
var obj1=obj2=p1=p2=null;
var id=0; //设置调用ID
var intval = 10; //单位豪秒,控制调用moveObj()的周期
var step = 5; //每次移动的像素,控制移动的速度
window.onload=function()
{
obj1=document.getElementById("obj1");
obj2=document.getElementById("obj2");
p1={x:obj1.style.pixelLeft,y:obj1.style.pixelTop};
p2={x:obj2.style.pixelLeft,y:obj2.style.pixelTop};
}
function moveObj()
{
{
if(p1.x<p2.x)
obj1.style.pixelLeft=p1.x+=step;
if(p1.y<p2.y)
obj1.style.pixelTop=p1.y+=step;
}
}
document.onmousedown=function()
{
if(id==0)
id=setInterval("moveObj()",intval);
}
document.onmouseup=function(){clearInterval(id);id=0;}
//-->
</script>
按下鼠标a移动,释放鼠标移动停止,再按下则继续移动。
<img src="a.gif" id="obj1" alt="a" style="position:absolute;left:100px;top:100px;"/>
<img src="b.gif" id="obj2" alt="b" style="position:absolute;left:500px;top:500px;"/>
ahu201
2007-05-28
打赏
举报
回复
点鼠标,a会向b游动---onclick事件改变a的style,
鼠标停,---什么时候动过?
a会停止---事件改变a的style。
btbtd
2007-05-28
打赏
举报
回复
有点难度...俺找时间整一下...
PS: 光会算法是不行滴, 还要非常熟悉DOM
cloudgamer
2007-05-28
打赏
举报
回复
不明白
Carignano
2007-05-28
打赏
举报
回复
通过onmousemove事件来改变a的style.top及style.left
dh20156
2007-05-28
打赏
举报
回复
通过设置对象的top及left来实现!
Java
求
a+b的值
求
取A+B的值并且输出 输入格式 输入为一行,包括了用空格分隔的两个整数 AA、BB(1 \le A, B \le 10001≤A,B≤1000)。 输出格式 输出为一行,为 A+BA+B 的结果。 输出时每行末尾的多余空格,不影响答案正确性 样例...
Python A*
算法
的简单实现
A*
算法
常用于游戏的寻路中,用于
求
解静态路网中的最短路径,是最有效的直接搜索方法。 这次正好花了几天时间学习了一下Python,便拿这个
算法
做了一下练习。这篇文章也
会
对其思路做一个简单介绍。 文章中的源码...
菜鸟
学
算法
-狄克斯特拉
算法
什么是狄克斯特拉
算法
狄克斯特拉
算法
用于解决有图的最短路径寻找,类似于深度优先
算法
,每次只走最短距离,走过的不在走,继续寻找最短距离,并不断更新到节
点
的开销-...起
点
--B--A A
点
开销更新为5 起
点
--B--A--...
算法
-动态规划 Dynamic Programming--从
菜鸟
到老鸟
前言最近在牛客网上做了几套公司的真题,发现有关动态规划(Dynamic Programming)
算法
的题目很多。相对于我来说,
算法
里面遇到的问题里面...一是帮助自己总结知识
点
,二是也能够帮助他人更好的理解这个
算法
。后面的参
菜鸟
都能理解的看毛片(KMP)
算法
看毛片
算法
的思想是用两个指针i和j来指示A和B中的一个位置 1) 用i来表示当前匹配到A中的哪个位置啦 2) 用j来表示当前匹配到B中的哪个位置啦 3) 并且要满足B[1...j]要和A[i+j-1...i]相等 哦?很难理解啊,下面的图(图...
JavaScript
87,996
社区成员
224,693
社区内容
发帖
与我相关
我的任务
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
分享
社区描述
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章