gpt4 book ai didi

jquery 无法在 'animate' : Partial keyframes are not supported 上执行 'Element'

转载 作者:行者123 更新时间:2023-12-01 04:36:16 25 4
gpt4 key购买 nike

我有以下代码。我正在尝试对 png 进行动画处理,使其看起来有拉伸(stretch)效果。但是当代码运行时,我收到错误:无法在“Element”上执行“animate”:不支持部分关键帧。

Jquery 在文档上初始化,就像在其他函数中使用一样。

任何帮助将不胜感激

$("#light-switch")[0].animate(
{height: "30%"} ,500, function(){
console.log("moved")
});
#light-switch{
z-index: 5;
width: 10%;
height: 25%;
position: absolute;
top:63%;
right:20%;
}
<div class="clickable" id="light-switch-link" >
<img id="light-switch" src="./images/switch-on.png" alt="light_switch" />
</div>
<!-- Scripts for bootstraps -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="./js/main.js" type="text/javascript"></script>

最佳答案

您正在 $("#light-switch")[0] 的索引中搜索,这是错误的。你不需要定义它。这将直接起作用 $("#light-switch").animate(.

这对你有用。

$("#light-switch").animate(
{height: "30%"} ,500, function(){
console.log("moved")
});
#light-switch{
z-index: 5;
width: 10%;
height: 25%;
position: absolute;
top:63%;
right:20%;
}
<div class="clickable" id="light-switch-link" >
<img id="light-switch" src="./images/switch-on.png" alt="light_switch" />
</div>
<!-- Scripts for bootstraps -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="./js/main.js" type="text/javascript"></script>

关于jquery 无法在 'animate' : Partial keyframes are not supported 上执行 'Element',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53465417/

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