js参数无效错误

s546489791 2011-10-27 05:39:52
<body>

<div id="one"></div>
<div id="two"></div>
<div id="three"></div>


<img id="sa" src="288180.jpg">
<input type="button" value="click me" onClick="start()">


<script type="text/javascript" language="javascript">
function $(ele){return document.getElementById(ele);}

var obj = $("sa");
obj.style.position = "absolute";
//obj.style.left = document.body.clientWidth - obj.offsetWidth;
//obj.style.top = document.body.offsetHeight;
obj.style.right = "0px";
obj.style.bottom = "-180px";
function start(){
var right = obj.style.right;
var bottom = obj.style.bottom;
if(bottom != 0){
var num = Number(obj.style.bottom);
num = num + 5;
obj.style.bottom = num; ************************
bottom = obj.style.bottom;

}
//setTimeout("start()",30);
}
window.onload = start;
</script>

</body>


打*号的那句(obj.style.bottom = num;),报 参数无效错误 ,忙烦大侠们,帮我看看,非常感谢啊,很着急用呢,十分感谢,
...全文
138 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hp2008001 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用楼主 s546489791 的回复:]
<body>

<div id="one"></div>
<div id="two"></div>
<div id="three"></div>


<img id="sa" src="288180.jpg">
<input type="button" value="click me" onClick="start()">


<script type="text/javas……
[/Quote]
改为var num = parseInt(obj.style.bottom);
ziyouren521125 2011-10-27
  • 打赏
  • 举报
回复
对不起,你上面还有个方法呢,没看到。

你只能打印下num看一下了。

或者后面+px
obj.style.bottom = num+"px";
ziyouren521125 2011-10-27
  • 打赏
  • 举报
回复
你用jquery了没吗?


你var obj = $("sa");这一行都不对啊,应该是
var obj = $("#sa");
liangws 2011-10-27
  • 打赏
  • 举报
回复
看看
var num = +obj.style.bottom + 5
obj.style.bottom = num;

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧