我想要个每隔15秒的 js图片抖动 指点指点。。。

daswcszxw 2011-12-22 02:42:07

<img id="win" style='position:relative' src="1.jpg">
<br /><br />
<button onclick="zd()">振动</button>
<script >
function zd(u){
var a=['top','left'],b=0;
u=setInterval(function(){
document.getElementById('win').style[a[b%2]]=(b++)%4<2?0:4;
if(b>15){clearInterval(u);b=0}
},32)
}
</script></font>


...全文
147 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
SqlServer2008 2011-12-22
  • 打赏
  • 举报
回复


<div id="win">
<img src="http://www.baidu.com/img/baidu_sylogo1.gif">
</div>
<br /><br />
<input type="button" onclick="zd()" value="振动">
<script >
function zd()
{
setTimeout("zd()",5000);

setTimeout(function(){document.getElementById("win").style.paddingLeft="10px"},200);
setTimeout(function(){document.getElementById("win").style.paddingTop="10px"},250);
setTimeout(function(){document.getElementById("win").style.paddingLeft="0px"},300);
setTimeout(function(){document.getElementById("win").style.paddingTop="0px"},350);


}
</script>

chenlin1019 2011-12-22
  • 打赏
  • 举报
回复
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<img id="win" style='position: relative' src="1.jpg" />
<br />
<br />
<button onclick="zd()">
振动</button>

<script type="text/javascript">
function zd(){
var a=['top','left'],b=0;
var u=setInterval(function(){
document.getElementById('win').style[a[b%2]]=(b++)%4<2?0:4;
if(b>15){clearInterval(u);b=0;setTimeout(zd,15000);}
},32)
}
</script>

</body>
</html>

lz你在抖动结束后再加个定时触发(时间间隔15s).
三石-gary 2011-12-22
  • 打赏
  • 举报
回复
<body>
<img id="win" style='position:relative' src="images/1.jpg">
<br /><br />
<button onclick="zd()">振动</button>
<script >
function zd() {
var a = ['top', 'left'], b = 0;
u = setInterval(function () {
document.getElementById('win').style[a[b % 2]] = (b++) % 4 < 2 ? 0:4+"px";
if (b > 15) { clearInterval(u); b = 0 }
},1500)
}
</script>
</body>
-晴天 2011-12-22
  • 打赏
  • 举报
回复
用 window.setTimeout() 来循环调用.
SK猫 2011-12-22
  • 打赏
  • 举报
回复
document.getElementById('win').style[a[b%2]]=(b++)%4<2?0:4 + "px";


chrome用户,打开控制条,执行下面代码,可以让CSDN的LOGO跳动


var a=['top','left'],b=0;
var u=setInterval(function(){
document.getElementsByTagName("img")[0].style[a[b%2]]=(b++)%4<2?0:4 + "px";
},100)

87,907

社区成员

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

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