具有以下html结构:
<tr class="invisible">
<td align="center">
<a class="i_edit" data-target="30"></a>
</td>
<td class="category">
<span class="f_type" style="background-image: url(/admin/assets/img/f_type_3.gif);"> Tests </span>
</td>
<td style="background-color: blue;">
<select class="behaviour" name="behaviour" style="opacity: 1;">
<option selected="" value="1" style="opacity: 1;">Por noticias destacadas</option>
<option value="2" style="opacity: 1;">Por fecha</option>
</select>
</td>
</tr>
这是访问.i_edit
内部课程的最佳/最快方式:
$('.behaviour').change(function(){
$(this).closest('.i_edit').css('background-color', 'red'); //doesn't work
$(this).parent().closest('.i_edit').css('background-color', 'red'); //doesn't work
$(this).parent().parent().find('.i_edit').css('background-color', 'red'); //this works
return false;
});