在网页加载时产生div? [英] Making a div shake on page load?

查看:140
本文介绍了在网页加载时产生div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有反正要使一个div框摇动页面加载?



更新:在此网址我仍然无法处理网页载入,做错了?
http://tinyurl.com/79azbav



我想我被困在负荷上;该失败可以在这里看到:
获取页面正常工作

我也尝试用我已经实现的 body onLoad 启动动画:

 < body onLoad =document.emvForm.EMAIL_FIELD.focus(); document.ready.entertext.shake(); > 

但是仍然失败像一个冠军。

解决方案

尝试这样:



EDIT >
为了与jQuery约定保持一致,已将 Shake()更改为 shake()

  jQuery.fn.shake = function(){
this.each(function(i){
$(this) .css({position:relative});
for(var x = 1; x <= 3; x ++){
$(this).animate },10).animate({left:0},50).animate({left:25},10).animate({left:0},50);
}
}
return this;
}

EDIT

在我的例子中, left position设置为 25 ,但是你可以减少这个更微妙的效果或增加



使用 shake 函数:

  $(#div)。 

这里有一个jsFiddle演示它:http://jsfiddle.net/JppPG/3/


Is there anyway to make a div box shake on page load? Like maybe just once or twice?

Update: At this URL I have it still not working on page load, what am I doing wrong? http://tinyurl.com/79azbav

I think I'm stuck at the onpage load; that failure can be seen here: Get onpage to work correctly

I've also tried initiating the animation with my already implemented body onLoad:

<body onLoad="document.emvForm.EMAIL_FIELD.focus(); document.ready.entertext.shake();" >

But still failing like a champ.

解决方案

Try something like this:

EDIT:
Changed Shake() to shake() for consistency with jQuery conventions.

jQuery.fn.shake = function() {
    this.each(function(i) {
        $(this).css({ "position": "relative" });
        for (var x = 1; x <= 3; x++) {
            $(this).animate({ left: -25 }, 10).animate({ left: 0 }, 50).animate({ left: 25 }, 10).animate({ left: 0 }, 50);
        }
    });
    return this;
} 

EDIT:
In my example the left position is set to 25, but you can reduce this for a more subtle effect or increase it for a more pronounced effect.

Using the shake function:

$("#div").shake();

Here's a jsFiddle that demonstrates it: http://jsfiddle.net/JppPG/3/

这篇关于在网页加载时产生div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆