1

Hi there I am using the PLYR Plugin to embed a vimeo video on my site. I want to add a string ("&background=1") at the end of an iframe src to hide the controls.

I am doing it like this:

var target="&background=1";

$(function(){
    $('iframe').each(function(){
        $(this).attr('src', $(this).attr('src')+target);
    });
});

But it doesnt work.

I appreciate any help.

Thanks.

beaver
  • 17,333
  • 2
  • 40
  • 66
Dennis
  • 75
  • 9

1 Answers1

1

Below is a little example which should help you out. I made a few changes to your code like removing the code from the wrapping function. I also removed the initial src so as we can add our new src. Hope it helps!

var target = "&background=1"
$('iframe').each(function(){
    var iframe_source = $(this).attr('src');
    var new_source = iframe_source + target;
    $(this).removeAttr('src');
    $(this).attr('src', new_source);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<iframe src="website.com"></iframe>
Derek Nolan
  • 744
  • 5
  • 11