title: remove image and its container if image is broken
body: <p>I am just trying to remove image and its title in case if image fails to load or broken using html or JavaScript.what is the best and easiest way to do that? </p>
  
  <pre><code>&lt;?php
  
  
     include("../includes/db.php");   // ../ means go to parent directory
    $query='SELECT * FROM `table` WHERE tag NOT IN("news") ORDER BY `id` DESC LIMIT 0,5';
    $run=mysqli_query($conn,$query);
    while($row=mysqli_fetch_array($run)){
           $img=$row['src'];
           $title=$row['title'];
     ?&gt;
  
         &lt;table class='mobileTable'&gt;
            &lt;tr&gt; &lt;td&gt;&lt;img src='&lt;?php echo $img ?&gt;' onerror='imgError(this)' /&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt; &lt;td  class='mobMidTitle'&gt;&lt;?php echo $title ?&gt;&lt;/td&gt;&lt;/tr&gt;//i want to remove this title as well
         &lt;/table&gt;
     &lt;?php } ?&gt;
  
   &lt;script&gt;
   function imgError(image) {
      image.onerror = "";
      image.src = "http://localhost/domain/images/error.jpg";
      document.getElementById('tit').style.display='none';
      return true;
  }&lt;/script&gt;
  </code></pre>
  
  <p>code above will fetch 5 images from database and with  javascript i can change image to error.jpg but i want to remove both image as well as its title only of failed image.</p>