我在html文檔中有一個圖像,當網頁加載時我希望圖像反彈。我有一個jquery函數,只有當圖像被點擊時纔會這樣做。我無法弄清楚如何使這項工作的onLoad ...jquery反彈動畫功能在文檔加載上工作
下面是代碼
<!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>
感謝您檢查了這一點。非常感激! :)
謝謝你們的幫助! – user1163073 2012-01-27 22:04:34
doc.ready不能確保圖像已加載。 – j08691 2012-01-27 22:07:17