对HTML来说是超级新手,但是我一直在尝试获取TweenTo(elem,dur,style)函数
从这个网页脚本

  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script>


这是我想实现该功能的地方

 <img id="mainPic" src="mainPic.jpg" style="margin-top:70px;position:relative ! important" class="img-responsive" alt="Responsive image" onclick="startAnimation()">
        <script type="text/javascript">
             function startAnimation(){
                 TweenTo(document.getElementById('mainPic'),1,{width:600px})
             }
        </script>


我完全不知道为什么在图片上调用onClick时为什么我无法运行此功能。
感谢所有帮助,谢谢:D

最佳答案

阅读您正在使用的库的文档


  https://greensock.com/tweenmax


function startAnimation(){
  TweenMax.to(document.getElementById('mainPic'),1,{width:'600px'})
}

关于javascript - 无法从脚本标签html获取函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39402558/

10-09 07:39