How to play youtube video on click action jquery

    This can be done simply by changing the source in the iframe tag with autoplay enabled:
    $('#clicked_item').click(function() {
        $("#wrapper_div_id iframe").attr('src', $("#wrapper_div_id iframe", parent).attr('src') + '?autoplay=1');
    });


    #clicked_item : ID of the item who click plays video
    #wrapper_div_id : ID of the div contaning video iframe or you can use iframe id directly

    5
    Average: 5 (1 vote)

    User login