I just stumbled upon a codepen demo. Then code works fine in codepen window. When, I copied it in a local HTML file it stopped working. Here is the code all combined in one .html file
我偶然发现了一个codepen演示。然后代码在codepen窗口中正常工作。何时,我将其复制到本地HTML文件中,它停止工作。这是所有组合在一个.html文件中的代码
click me
0
You need to use your script code in $.ready() LIKE,
script code
你需要在$ .ready()LIKE中使用你的脚本代码,
$(function(){ window.requestAnimFrame = (function () { .... .... })(); });
As your script is loaded first but it doesn't find any DOM element, so it not works.
由于您的脚本首先被加载但它没有找到任何DOM元素,所以它不起作用。
Also you don't need to include jquery, as you are not using any jquery functionality in your code so try it like,
此外,您不需要包含jquery,因为您没有在代码中使用任何jquery功能,所以试试它,
It might help to put the script tags inside the tags.
将脚本标记放在 标记内可能会有所帮助。