If my image doesnt contain a src then i want to hide it using visibility hidden:
<img border="0" src="" style="cursor:hand;cursor:pointer;" id="EntityPic543">
How can i do this with jquery?
If my image doesnt contain a src then i want to hide it using visibility hidden:
<img border="0" src="" style="cursor:hand;cursor:pointer;" id="EntityPic543">
How can i do this with jquery?
Share Improve this question asked Jul 19, 2012 at 10:56 SOLDIER-OF-FORTUNESOLDIER-OF-FORTUNE 1,6545 gold badges39 silver badges68 bronze badges 1-
2
Please note that if your
img
tag haswidth
&height
attributes it will still occupy some space when usingvisibility:hidden
. Most of the answers will make yourimg
display:none;
– Bob Commented Jul 19, 2012 at 11:03
5 Answers
Reset to default 4$('img').filter(function(index){return $(this).attr('src')==='';}).hide();
$(document).ready(function(){
$("img").each(function(){
(!this.src || $(this).prop("src")) && $(this).hide();
});
});
Thanks to @GeorgeMauer
$('img').each(function() {
!this.src && $(this).hide()
});
Try this without any loop:
$('img[src=""]').hide();
DEMO
$("#EntityPic543").css("visibility", "hidden");
That will hide the element.