jquery: how to remove youtube videos from html popups?

267 views Asked by At

I have youtube video played on the html popup and I want to remove the popup, including the youtube when I click remove the popup button.

$(".ei-popup-overlay").remove();

But it only removes the html layers, and does not remove the youtube video.

html popup,

<div class="ei-popup-overlay">

    <div class="ei-popup-content-holder">

        <a href="#" class="ei-button-popup-close hide-text">x</a>
        <div class="ei-popup-content">

            <iframe src="http://www.youtube.com/embed/c-gARuGBSdw?autoplay=1" frameborder="0" width="800" height="490"></iframe>        </div>

    </div>

</div>

jquery,

(function($){

    $.fn.extend({ 

        video_player: function(options) {

            var defaults = {
                button: null,
            }

            var options =  $.extend(defaults, options);
            var o = options;

            var $this = this;

            // Attach click function.
            return this.click(function(){

                ...

                $.ajax({
                    type: "GET",
                    url: "popup.php?url=" + request,
                    dataType: "html",
                    success: function (html) {

                        // Prepend html into the target element. 
                        $('body').prepend(html);

                    },
                    complete: function () {

                        $(".ei-button-popup-close").click(function(){

                            $(".ei-popup-overlay").remove();


                            return false;
                       });
                    }
                });

                return false;

            });



        }
    });

})(jQuery);

Any ideas what I have missed?

0

There are 0 answers