如果没有src,则使用jquery隐藏图像

hide image using jquery if it has no src

本文关键字:jquery 隐藏 图像 src 如果没有      更新时间:2023-11-17

如果我的图像不包含src,那么我想使用visibility hidden:来隐藏它

<img border="0" src="" style="cursor:hand;cursor:pointer;" id="EntityPic543">

我如何使用jquery做到这一点?

$('img').filter(function(index){return $(this).attr('src')==='';}).hide();
$(document).ready(function(){
  $("img").each(function(){
     (!this.src || $(this).prop("src")) && $(this).hide();
  });
});

感谢@GeorgeMaier

$('img').each(function() { 
  !this.src && $(this).hide()
});

在没有任何循环的情况下尝试这个:

$('img[src=""]').hide();

演示

$("#EntityPic543").css("visibility", "hidden"); 

这将隐藏元素。