title: jQuery condition applied to multiple items
body: <p>I am trying to #1 get the file extension and then once I have that -conditionally display a corresponding icon to show what file type it is. I got it to detect the extension, I got it to work the first time, I can't get it to treat each item differently.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>   &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;check ext&lt;/title&gt;
  
  
  
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"&gt;&lt;/script&gt;
      &lt;script&gt;
  $(document).ready(function(){
  
  
  $("div").each(function(){ 
  var fileName =$('div img.myimg').attr('src')
  var fileExtension = fileName.substring(fileName.lastIndexOf('.') );
  
  
  
  if (fileExtension==".jpg")
  {
     $(this).next().find("#indicator").addClass("isjpg");
  }
  else (fileExtension==".gif")
  {
     $(this).next().find("#indicator").addClass("isgif");
  
  }
  
  
   });
  
  
  
   });
  
  &lt;/script&gt;
  
  &lt;style&gt;
  .isjpg{background-image:url('images/jpg.gif');}
  .isgif{background-image:url('images/gif.gif');}
  
  #indicator{width:100px;height:100px;border:solid;border-width:1px;}
  &lt;/style&gt;
  
  
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div&gt;
  &lt;img class="myimg" src="images/carthumb.jpg"/&gt;&lt;div id="indicator"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div&gt;
  &lt;img class="myimg" src="images/plus.gif"/&gt;&lt;div id="indicator"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div&gt;
  &lt;img class="myimg" src="images/carthumb.jpg"/&gt;&lt;div id="indicator"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>