Marcus Silverman
Marcus Silverman

Reputation: 243

Stop YouTube video from playing when div is closed

How do I stop the YouTube video from playing when the div is closed?

Demo: http://defroster.99k.org/layers.php

THANKS

Upvotes: 1

Views: 1383

Answers (1)

fedmich
fedmich

Reputation: 5371

If you dont want to use the js_api_reference...

You'll need to clear the div object by doing

$('#slidingDiv').html('');  or rebuild the html

after the sliding is finished, and then rebuild the html content again when you activate that.

try this http://jsfiddle.net/fedmich/GTedm/

$('#slidingDiv').slideToggle('', function (){
    var obj = $(this);
    if(obj.is(':hidden')){
        obj.html( obj.html() );
    }
});

Upvotes: 1

Related Questions