【问题标题】:jquery Failed to execute 'animate' on 'Element': Partial keyframes are not supportedjquery 无法在“元素”上执行“动画”:不支持部分关键帧
【发布时间】:2018-11-25 07:11:44
【问题描述】:

我有以下代码。我正在尝试为 png 设置动画,使其看起来可以拉伸。但是当代码运行时,我收到错误: 在“元素”上执行“动画”失败:不支持部分关键帧。

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>

【问题讨论】:

    标签: jquery jquery-animate


    【解决方案1】:

    您在 $("#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>

    【讨论】:

      猜你喜欢
      • 2016-11-17
      • 1970-01-01
      • 2017-12-21
      • 2018-08-27
      • 2017-04-25
      • 1970-01-01
      • 2021-09-15
      • 2022-01-19
      • 2019-07-01
      相关资源
      最近更新 更多