How to play/start youtube video after clicking on an image?

后端 未结 5 1478
旧巷少年郎
旧巷少年郎 2020-12-30 03:02

I have an image and I want to start a youtube video only after I click the image. How can I do this?

Thanks a lot!

5条回答
  •  佛祖请我去吃肉
    2020-12-30 03:33

    Another approach - switch iframe SRC (URL) with "?autoplay=1" version.

    PLAY
    
    
    

    jQuery:

    jQuery("#clickMe").on('click',function(){
        var vi = jQuery("#iframe");
        vi.attr("src", vi.data("autoplay-src") );
    });
    

提交回复
热议问题