Note that there are some explanatory texts on larger screens.

plurals
  1. POHide image if src is empty
    primarykey
    data
    text
    <p>I'm trying to hide <code>&lt;img&gt;</code> if the source is empty. But I have no luck.</p> <p>I found few posts here, but it doesn't work for me. </p> <p>Here is my code, it's table based because it will be a template: Images:</p> <pre><code>&lt;td width="92%" align="center" class="imagenes_desc"&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="http://webs.ono.com/norfolk/ebay/images/01.jpg" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;a href="#" class="showcase"&gt;&lt;img class="imagen" src="" width="800"&gt;&lt;/a&gt; &lt;/td&gt; </code></pre> <p>Here is the Javascript I'm trying to implement.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ if ($(".imagen").attr(src="") == "") { $(".imagen").hide(); } else { $(".imagen").show(); } &lt;/script&gt; </code></pre> <p>I'm not very familiar with JS, I found this script here on Stackoverflow, but I can't get it to work.</p> <p><strong>Update</strong></p> <p>Trying this, but doesn't work (Chrome hides well, but Firefox and IE don't):</p> <pre><code>&lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $("imagen").each(function(){ if ($(this).attr("src") == "") $(this).hide(); else $(this).show(); }); &lt;/script&gt; &lt;style&gt; .hide {display:none !important;} .show {display:block !important;} &lt;/style&gt; </code></pre> <p>Thanks,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload