点击一次,网页就往下滚动50像素 比如点击一个图片, 里面的某个 div 内容就往下滚动一次。 这样的JS该怎么样写啊?O(∩_∩)O谢谢谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你写了个最简单的,参考一下吧<div style="width:100px;height:300px;background-color:red;overflow:hidden"> <div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px"> </div></div><input type="button" value="button" onclick="abc()"><script type="text/javascript"> var i=0; var sd=2; var time; function abc() { time=setTimeout("abc()",10); if(i<50) { document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+2+"px"; i=i+sd; } else { clearTimeout(time); i=0; } }</script> document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+sd+"px";改一下 document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+sd+"px";改一下 在一个面页里同时加载了 onmousedown 事件和onclick 事件? 怎样实现页面不可点击 纯js网页大型游戏:《神魔对决2-天上的激战》(3.8M),开源发布。 200多个JS代码(自调颜色) 各位大侠,请帮忙做一个小程序,小弟刚学不会做,请帮忙!!多谢!!! 如果在一个已有的DIV中创建新的DIV 求高手修改一个效果 帮我看一看,2和10为什么不能比较大小 关于页面自动添加控件的问题,急 如何四舍五入保留到小数点后两位!! 问什么页面无法跳转 60分啦!!马上给分
<div style="width:100px;height:300px;background-color:red;overflow:hidden">
<div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px">
</div>
</div>
<input type="button" value="button" onclick="abc()">
<script type="text/javascript">
var i=0;
var sd=2;
var time;
function abc()
{
time=setTimeout("abc()",10); if(i<50)
{
document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+2+"px";
i=i+sd;
}
else
{
clearTimeout(time);
i=0;
}
}
</script>
document.getElementById("a").style.marginTop=document.getElementById("a").
style.marginTop.replace("px","")-0+sd+"px";改一下