froogaloop: $ is not defined

谁说胖子不能爱 提交于 2019-12-11 21:09:34

问题


I'm using the froogaloop library for embedding Vimeo videos and I came across this error. I took all the code right from Vimeo's site (https://developer.vimeo.com/player/js-api).

I have linked the Javascript library earlier in the code then when the code below is executed.

Any ideas?

Web Console Error: "ReferenceError: $ is not defined"

Javascript code:

$(function() {
var iframe = $('#player1')[0];
var player = $f(iframe);
var status = $('.status');

// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
    status.text('ready');

    player.addEvent('pause', onPause);
    player.addEvent('finish', onFinish);
    player.addEvent('playProgress', onPlayProgress);
});

// Call the API when a button is pressed
$('button').bind('click', function() {
    player.api($(this).text().toLowerCase());
});

回答1:


You are either loading jQuery after this code or not at. You need to include jQuery before this script.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>


来源:https://stackoverflow.com/questions/30202865/froogaloop-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!