title: How to change width of div to 100% with jQuery?
body: <p>I have 2 divs side by side and when one isn't there, I want the other to have a width of 100%. </p>
  
  <pre><code>while ($array = $query-&gt;fetch(PDO::FETCH_ASSOC)){    
       if (!empty($array['photoname'])){
            echo '&lt;div class="photo"&gt;&lt;/div&gt;';
       }
          echo  '&lt;div class="info"&gt;&lt;/div&gt;';
  }
  </code></pre>
  
  <p>Here's my Javascript/jQuery:</p>
  
  <pre><code>$(document).ready(function() {
      //check if photo div exists
      if ($('.photo').length){
  
      }else{
          $('.info').css('width', '100%');
      }
  });
  </code></pre>
  
  <p>So if there is no photo div I want the info div to get a width of 100%. How can I achieve this?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>If I don't have any photo divs showing, the above works and sets info divs to 100%. But when I have a photo div anywhere on the page, then none of the info divs are set to 100% even if they dont have a photo div next to them.</p>