title: Comparing element ids in jquery
body: <p>I'm trying to compare two element ids in jQuery with the following code.</p>
  
  <pre><code>if($("#pic" + i).attr("id") == ($this.attr("id")))
  </code></pre>
  
  <p>If I try to retrieve the ids individually I can, but when I try to compare them within the if statement it crashes my script, and I'm not sure why.</p>
  
  <p>EDIT: The entire piece of code.</p>
  
  <pre><code>$(document).ready(function() {
      $(".slideshow").click(function() {
          $("#pic0").attr('class', 'a');
          $("#pic6").attr('class', 'a');
  
  
          $(this).css('z-index', 1);
          $(".slideshow").animate({
              left: '10px'
          }, 1000);
  
          for (var i = 1; i &lt; 6; i++) {
              alert($("#pic" + i).attr("id"));
              alert($(this).attr("id"));
  
              if ($("#pic" + i).attr("id") == ($this.attr("id"))) {
                  $("#pic" + i).removeClass("boxShadow");
                  alert("Doesn't");
              }
          }
  
          $("#contenttable").show();
          $("#contenttable").animate({
              width: '1200'
          }, 1000);
          $("#fadecontent").fadeIn(4000);
  
          $("#pic0").attr('attr', "slideshow");
          $("#pic6").attr('attr', "slideshow");
      });
  });
  </code></pre>