Jquery反弹动画函数来处理文档加载
Jquery bounce animate function to work on document load
我在html文档中有一个图像,当网页加载时,我希望图像反弹。我有一个jquery函数,它只在点击图像时才执行此操作。我不知道如何在Load。。。
这是代码
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style type="text/css">
div { margin-left: 500px; margin-top: 200px; width: 100px; height: 80px; position: relative; }
</style>
<script>
$(document).ready(function() {
$("#logo").click(function () {
$(this).effect("bounce", { times:4, distance:200 }, 400);
});
});
</script>
</head>
<body>
<div id="logo"><img src="http://visionhelp.files.wordpress.com/2012/01/soccer-ball.jpg"/> </div>
</body>
</html>
谢谢你查看这个。非常感谢!:)
$(document).ready(function () {
$("#logo").effect("bounce", { times:4, distance:200 }, 400);
});
或者,使用更现代风格的文档准备功能:
$(function () {
$("#logo").effect("bounce", { times:4, distance:200 }, 400);
});
这适用于您:
$(window).load(function() {
$('#logo').effect("bounce", {
times: 4,
distance: 200
}, 400).click(function() {
$(this).effect("bounce", {
times: 4,
distance: 200
}, 400);
});
})
使用jsFiddle示例
只需在页面加载时触发click
事件。试试这个
$(document).ready(function() {
$("#logo").click(function () {
$(this).effect("bounce", { times:4, distance:200 }, 400);
})
.click();//Will trigger the click event on page load
});
如果你不想在徽标点击上有这种效果,而只是在页面加载上,那么就使用这个。
$(document).ready(function() {
$(this).effect("bounce", { times:4, distance:200 }, 400);
});
相关文章:
- 是否存在Javascript Liferay Service库的文档?如何处理错误情况
- 使用mongoose保存多个文档时的错误处理
- RxJs如何处理文档事件
- 在火狐插件中处理右键单击,仅适用于文档
- 如何使用 AngularJS 处理文档单击并通知其他控制器
- 将 AJAX 响应作为文档处理
- 谷歌脚本 - 将 Gmail 附件添加到文档和云端硬盘中的处理
- 文档.写入和委托事件处理程序持久性
- Twitter 引导弹出窗口 :如何在不使用正文/文档事件处理程序的情况下在外面单击时隐藏它
- 处理上传的文本文件后,在Google云端硬盘中创建新的文档
- 阻止删除在准备就绪的文档上分配的处理程序
- CouchDB更新处理程序:文档id不能为空
- 函数没有'我不处理文档
- 如何在嵌入式文档中处理DOM事件
- 为什么toggle()能处理文档而不能处理正文
- Jquery反弹动画函数来处理文档加载
- Jquery trigger()无法处理文档就绪
- firefox中的Ajax调用无法处理文档准备事件
- 如何处理文档从mongoDB与_bsontype属性
- 使用JQuery处理文档对象