text: Q:
  
  Check condition with w\ jQuery
  
  I have the following HTML code:
  <div class="container">
         <span class="red"></span> 
         <span class="hot"></span> 
  </div>
  
  On click I need to check if one of the elements has a particular class and if yes change it to another class. I think I'm having difficulty with targeting correct element.
  $(".container").click(function() {
  if ($(this).next().hasClass('red')) {
      $(this).find("red").removeClass("red").addClass("blue");
              $(this).find("hot").removeClass("hot").addClass("cold");
              // and a line of back-end code if condition is true
  }
  
  What am I missing?
  
  A:
  
  $(this).find(".red").removeClass("red").addClass("blue");
  $(this).find(".hot").removeClass("hot").addClass("cold");
  
  You need to add a dot to the find param because it is a class.
  EDIT
  if ($(this).next().hasClass('red')) {
  
  will never happen in your example. because the element with the red class is the first item in the container.** 
  EDIT2
  $(".container").click(function() {
      $('span', this).each(function() {
          if ($(this).hasClass('red')) {
              $(this).removeClass('red');
              $(this).addClass('blue');
          }
  
          if ($(this).hasClass('hot')) {
              $(this).removeClass('hot');
              $(this).addClass('cold');
          }
      });
  });
  
  Not sure if I understand you. But what this does is:
  loop through all spans in the container.
  check if the span has a specific class.
  if so change class.
  Let me know if I understood you right.
  EDIT 3
  $(".container").click(function() {
      $('span.red', this).removeClass('red').addClass('blue');
      $('span.hot', this).removeClass('hot').addClass('cold');
  });
  
  or if you only want to check the first span for a red class and the second span for the hot class use this:
  $(".container").click(function() {
      var span = $('span', this);
          if ($('span', this).eq(0).hasClass('red')) {
              // do stuff if first span has class red
          }
  
          if ($('span', this).eq(1).hasClass('hot')) {
              // do stuff if second span has class hot
          }
      });
  });
  
  Last edit: :)
  $(".container").click(function() {
      if ($('span:first', this).hasClass('red')) {
          $('.red', this).removeClass('red').addClass('blue');
          $('.hot', this).removeClass('hot').addClass('cold');        
          // and a line of back-end code if condition is true
      }
  });
  
  http://jsfiddle.net/TaCsV/
  
  