Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 1.11 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Fastest way to access a class after $(this)
  2. <tr class="invisible">
  3.     <td align="center">
  4.         <a class="i_edit" data-target="30"></a>
  5.     </td>
  6.     <td class="category">
  7.         <span class="f_type" style="background-image: url(/admin/assets/img/f_type_3.gif);"> Tests </span>
  8.     </td>
  9.     <td style="background-color: blue;">
  10.         <select class="behaviour" name="behaviour" style="opacity: 1;">
  11.             <option selected="" value="1" style="opacity: 1;">Por noticias destacadas</option>
  12.             <option value="2" style="opacity: 1;">Por fecha</option>
  13.         </select>
  14.     </td>
  15. </tr>
  16.        
  17. $('.behaviour').change(function(){
  18.  
  19.         $(this).closest('.i_edit').css('background-color', 'red'); //doesn't work
  20.         $(this).parent().closest('.i_edit').css('background-color', 'red'); //doesn't work
  21.         $(this).parent().parent().find('.i_edit').css('background-color', 'red'); //this works
  22.  
  23.     return false;
  24.  
  25. });
  26.        
  27. $('.behaviour').change(function(){
  28.     var obj_this = $(this)
  29.  
  30.     obj_this.parents('tr.invisible').find('.i_edit').css('background-color', 'red');
  31.  
  32.    return false;
  33. });
  34.        
  35. var obj_this = $(this)