gpt4 book ai didi

jquery - 在 jQuery 中制作动画框时遇到问题

转载 作者:行者123 更新时间:2023-11-28 08:17:32 25 4
gpt4 key购买 nike

我试图在 jQuery、CSS 和 HTML 中制作 2 个动画框,但代码不起作用。我在 jQuery 教程应用程序中制作了该应用程序,它在该应用程序上运行良好。当我在我的 PC 上使用确切的代码时,它不起作用。我的代码有什么问题?

这是我的代码:

    <!doctype html>
<html>
<head>
<title>Testing Stuff</title>
</head>
<body>
<div class="blueBox"></div>
<div class="redBox"></div>
<style>
.blueBox, .redBox {
width: 100px;
height: 100px;
top: 20px;
position: absolute;
}
.redBox {
left: 20px;
background-color: red;
}
.blueBox {
left: 140px;
background-color: blue;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
var $blueBox = $('div.blueBox');
var $redBox = $('div.redBox');
$blueBox.animate({left: "500px"}, 2000, function(){alert("Animation Completed!");
});
$redBox.animate({width: "0px", height: "0px", opacity: "0"}, 3000);

});

</script>
</body>
</html>

谢谢你帮助我!!

最佳答案

您需要在 HTML 中链接 jQuery 代码:

<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>

最好在标签中完成。

如果你想要above v1.11.1 ,通过jQuery download page直接从版本中获取代码链接.例如:

<script src="http://code.jquery.com/jquery-2.1.3.min.js"
type="text/javascript"></script>

关于jquery - 在 jQuery 中制作动画框时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28919023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com