Change action on click if div has a different class
<p>I have a number of divs withing a container. When one of the divs is clicked I compare  the ID of that div and the one that has a class "CURRENT" and if they are not the same I do something.</p>

<p>I would like to add another condition, to check if the class "red" is there instead of "green" and if yes, show an alert. I tried the code below but I think I might be checking it wrong, as I get an alert when I click on any div withing "main"...</p>

<pre><code>&lt;div id="main"&gt;
   &lt;div id="1"&gt;&lt;span class="red"&gt;&lt;/span&gt;Label 1&lt;/div&gt;
   &lt;div id="2"&gt;&lt;span class="red"&gt;&lt;/span&gt;Label 2&lt;/div&gt;
   &lt;div id="3"&gt;&lt;span class="green current"&gt;&lt;/span&gt;Label 3&lt;/div&gt;
   &lt;div id="4"&gt;&lt;span class="green"&gt;&lt;/span&gt;Label 4&lt;/div&gt;
&lt;/div&gt;

$('#main div').live('click', function() {

   var ct = $('.current').attr('id');
   var cc = $(this).attr('id');

   // need to add conditional statement
   // if ($(this).find('.red')) {
   //    alert("Has red class");

   if (ct != cc) {
      // do something
   }

});
</code></pre>
