<td width="162"><span class="required">*</span> Name:</td>
<td width="407">
<label>
<input id="store_name" class="text_field alnum" type="text" minlength="3"
maxlength="30" size="40" name="store_name" style="color: rgb(51, 51, 51);"/>
</label>
</td>
<td class="char_count_area" style="color: green;"/>
我有一些jQuery代码,像这样:
$('.text_field').each(function(){
$(this).keyup(function(){
$(this).parent().parent().parent().find('.char_count_area').html(remainingChars);
....
正如您所见,我正在试图以一种相当低效的方式从text_field
到达char_count_area
。虽然它能工作,但是如果稍微更改表格设计,它就会变得非常混乱。我已经尝试过使用。
$(this).closest('.char_count_area').html(remainingChars)
但它不起作用(字符不显示)。
我如何使用closest
实现这一点?