Guest User

Show/hide img borders

a guest
Oct 26th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.91 KB | None | 0 0
  1. Option #1: produce an img tag only if there is a location:
  2.  
  3. while($row=$result->fetch()){
  4.     //...
  5.     if(!$row['location']==''){                          // Check if the location IS NOT empty
  6.         echo '<img scr="' . $row['location'] . '">';
  7.     }
  8. }
  9.  
  10. Option #2: produce the img tag anyway (to preserve space maybe), but specify a style attribute to it if empty location.
  11.  
  12. while($row=$result->fetch()){
  13.     //...
  14.     echo '<img scr="' . $row['location']';              // the img tag isn't closed yet...
  15.     if($row['location']==''){                           // If the location IS empty
  16.         echo '" style="border:0 !important;">';         // Specify style and close the tag.
  17.     }else{
  18.         echo '">';                                      // Just close the img tag.
  19. }
  20.  
  21. Option #3: a script to remove the border on empty images, client side.
  22.  
  23. <script>
  24.     $(document).ready(function(){
  25.         $("img").each(function(){
  26.             if($(this).attr("src")==""){
  27.                 $(this).css({"border":"0 !important"});
  28.             }
  29.         });
  30.     });
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment