如何仅定位youtube iframe网址?

Bry*_*ler 4 youtube jquery

我正在寻找一种方法来定位这个jquery只在src url中有"youtube.com".我已经尝试使用:contains选择器,但我无法正常工作.

jQuery(document).ready(function($){

    $('iframe').each(function() {
        var url = $(this).attr("src")
        $(this).attr("src",url+"&wmode=transparent")
    }); 

});
Run Code Online (Sandbox Code Playgroud)

Aar*_*ron 16

使用属性选择器仅定位src包含youtube.com以下内容的iframe :

jQuery(document).ready(function($){

    $('iframe[src*="youtube.com"]').each(function() {
        var url = $(this).attr("src")
        $(this).attr("src",url+"&wmode=transparent")
    }); 

});
Run Code Online (Sandbox Code Playgroud)