代码之家  ›  专栏  ›  技术社区  ›  Ross Goddard

jQuery-查找下一个具有特定子元素的元素

  •  5
  • Ross Goddard  · 技术社区  · 17 年前

    <tr>
    <td><input type="text" /></td>
    <td>Somevalue</td>
    <td><intput type="text /></td>
    </tr>
    

    3 回复  |  直到 17 年前
        1
  •  6
  •   TJ L    17 年前

    this

    var next = $(this).parent().next("td > input[type='text']");
    
        2
  •  0
  •   Maher Abuthraa    9 年前

    这可能是因为jQuery的更新版本。我想到了这个:

    var next = $(this).parent().nextAll().has("input[type='text']").first();
    
        3
  •  -1
  •   exbios    14 年前

    $(function(){ 
    
        $(':input').each(function(){
            $(this).keypress(function(){
              $(this).next('input[type=text]').val('I\'m the next');
         }) // end of keypress
        }) // enf of each
    }) // End of function