注册 登录
编程论坛 JavaScript论坛

为什么向左移动不了?

发光 发布于 2010-12-06 10:36, 492 次点击
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function upmove()
{
    var startTop=document.getElementById("zfg").style.posTop;
    document.getElementById("zfg").style.posTop=startTop-10;
}
function downmove()
{
    var startTop1=document.getElementById("zfg").style.posTop;
    document.getElementById("zfg").style.posTop=startTop1+10;
}
function rightmove()
{
    var startTop2=document.getElementById("zfg").style.posLeft;
    document.getElementById("zfg").style.posLeft=startTop2+10;
}
function leftmove()
{
    var startTop3=document.getElementById("zfg").style.posLeft;
    document.getElementById("zfg").style.posLeft=startTop3-10;
}
function hidemove()
{
    var pic=document.getElementById("zfg");
  pic.style.display="none";
}
function showmove()
{
    var pic=document.getElementById("zfg");
    pic.style.display="block";
}
</script>
<style type="text/css">
#css {
    background-color: #999;
    height: 180px;
    width: 200px;
    position: absolute;
    left: 147px;
    top: 80px;
}
-->
</style>

</head>

<body>
<input name="rightmove" type="button" value="向右移动10pt" onclick="rightmove()">
<input name="leftmove" type="button" value="向左移动10pt" onclick="leftmove">
<input name="upmove" type="button" value="上移10pt" onclick="upmove()">
<input name="downmove" type="button" value="下移10pt" onclick="downmove()">
<input name="hidemove" type="button" value="隐藏" onclick="hidemove()">
<input name="showmove" type="button" value="显示" onclick="showmove()">
<FORM> <INPUT TYPE='BUTTON' value='关闭' onClick='window.close()'> </FORM>
<div id="zfg" style="background-color: #999;height: 180px;width: 200px;position: absolute;left: 147px;top: 80px;">可单击上面按钮进行操作</div>
 
</body>
</html>
3 回复
#2
筱晓绾2010-12-06 10:41
onclick="leftmove">问题是你的点击事件调用方法的时候 少了()应该是
<input name="leftmove" type="button" value="向左移动10pt" onclick="leftmove()">
#3
发光2010-12-06 15:59
回复 2楼 筱晓绾
汗...
#4
xwanq2010-12-06 16:59
做什么都要细心啊,我也很受教!
1