WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
$ not defined using jQuery in Wordpress

I need to trigger a alert box when video ends

THis is the code i got from google

$("iframe[src^='http://www.youtube.com']").bind("ended", function() {
alert("I'm done!");

I am just using the oembed function of wordpress to play youtube videos

I dont now why there are not working

share|improve this question

marked as duplicate by Tom J Nowell, brasofilo, toscho Jan 28 '13 at 12:51

This question was marked as an exact duplicate of an existing question.

Voted to close as off topic, this is a Youtube player issue, not a WordPress issue. The embed itself is defined by Youtube, as is the API, as is the JS, as is the player controls. This is a Javascript question should belongs on the main Stack Overflow site – Tom J Nowell Jan 28 '13 at 10:56
i added here becuase the script works in normall php sites but doesnt works in wordpress as wordpress is using o-embed function to embed videos – vaibhav Jan 28 '13 at 11:15
So it is not a WordPress issue it's an OEmbed issue? Then it's still offtopic – Tom J Nowell Jan 28 '13 at 11:54

You can track the state of the youtube video, do you have the link to the youtube video? Use this youtube API function to get the result, and if it hits you back with a "0" you can initiate the alert(); function


Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.