jquery 无法在 'Element' 上执行 'animate':不支持部分关键帧
jquery Failed to execute 'animate' on 'Element': Partial keyframes are not supported
我有以下代码。我正在尝试为 png 设置动画,使其看起来可以拉伸。但是当代码运行时,我收到错误:
无法在 '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>
我有以下代码。我正在尝试为 png 设置动画,使其看起来可以拉伸。但是当代码运行时,我收到错误: 无法在 '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>