Stop a youtube video with jquery?

wesbos picture wesbos · Jan 24, 2010 · Viewed 194.3k times · Source

I have a jquery slider that I have built, basically just three pannels that slide by applying negative left CSS values. Works great, but I have a youtube video in one slide that wont stop when I slide. I've tried display:none and Visibility:hidden which works in all but IE, the audio keeps going in IE.

Is there an easy way to kill a video with jquery?

Answer

HeyTiger picture HeyTiger · Jan 27, 2012

This solution is simple, elegant and works in all browsers:

var video = $("#playerid").attr("src");
$("#playerid").attr("src","");
$("#playerid").attr("src",video);