froogaloop: $ is not defined

2019-09-02 08:47发布

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条回答
放荡不羁爱自由
2楼-- · 2019-09-02 09:43

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>
查看更多
登录 后发表回答