Search code examples
jqueryvimeoattrvimeo-apiautoplay

Applying attr to an iframe


I'm trying to apply attr allow="autoplay; to my iframe shown in this image.

enter image description here

I've tried

jQuery(".esg-entry-media-wrapper iframe").attr("allow", "autoplay;");

But it's not working.

EDIT : Works with the code below.

jQuery("document").ready(function() {
    setTimeout(function() {
     jQuery(".esg-vimeo-frame").attr('allow', 'autoplay');  

    },1000);
});

Solution

  • your iframe doesn't have .esg-entry-media-wrapper class what you should do is give right class.

    jQuery(".esg-vimeo-frame").attr("allow", "autoplay;");

    Edit:

    • Maybe you should wait until the DOM is ready and then assign that attribute to an element