jQuery.查找元素' script或noscript或iframe '中/下具有属性键为' src或href '的所

jQuery. Find all attribute values within/under elements `script or noscript or iframe` that have attribute keys as `src or href`

本文关键字:属性 href src 的所 script 元素 查找 noscript iframe jQuery      更新时间:2023-09-26

我希望能够找到所有属性值,有属性键src或href下的元素('script', 'noscript', 'iframe')。

大家好,请看这里:http://jsbin.com/kizix/1/edit

   $(function(){
    var elements = $("iframe[src], script[src], noscript[src]");
    $.each(elements, function(index,element){
      var src = $(element).attr('src');
      $('#sr').append(src + "<br/>");
    });
    });

试试这个:

$("iframe[src], script[src]").each(function() {
console.log($(this).attr('src'));
});