Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide images without src

Tags:

jquery

Im generating my page content on the serverside and sometimes as reault I have an image without src. Is it possible to hide all such images using jquery so that ugly icons arent visible for example in chrome ?

thanks for help

like image 308
gruber Avatar asked May 11 '26 16:05

gruber


2 Answers

You are not supposed to have any <img/> tags without a src attribute!

But you can use $('img:not([src]), img[src=""]') to select images with empty or missing src attrs.

like image 189
ThiefMaster Avatar answered May 13 '26 06:05

ThiefMaster


More complete answer derived from ThiefMaster would be on the following lines

$.each($('img:not([src]), img[src=""]'),function(index, value) { 
 value.css('display','none');
});
like image 36
Sap Avatar answered May 13 '26 07:05

Sap