Mario Parra Mario Parra - 8 months ago 42
Javascript Question

Script to resize embedded YouTube videos

I'm trying to write a jQuery script that resizes all embedded YouTube videos to 746px x 420px, but it's not having any effect.

I'm using this approach as I recently adjusted my website's layout and I can't really go back and update the iframes individually. I've got separate CSS handling responsiveness.


jQuery('iframe[src^="//"]').attr('width', '746px').attr('height', '420px');

Any help would be appreciated. Thanks!


$('iframe[src*=""]').each(function() {
    var url = $(this).attr("src")
   $(this).attr('width', '73px').attr('height', '42px');