我获取textbox1的父元素的父元素的下一个同级元素的类型为textbox1的子元素
<tr><td>
                        <span id="GridView1_ctl03_chinese"> 日本人</span>
                    </td><td>
                        <span id="GridView1_ctl03_type">名</span>
                    </td><td>
                        <input name="GridView1$ctl03$japanese" type="text" id="GridView1_ctl03_japanese" onkeydown="textboxfocus('this')" style="width:150px;" />
                    </td>
</tr><tr>
<td>
                        <span id="GridView1_ctl04_chinese"> 韩国人</span>
                    </td><td>
                        <span id="GridView1_ctl04_type">名</span>
                    </td><td>
                        <input name="GridView1$ctl04$japanese" type="text" id="GridView1_ctl04_japanese"  onkeydown="textboxfocus('this')" style="width:150px;" />
                    </td>
</tr>
元素都是动态生成的,我只能写到这里,还不知道对不对,请问后面怎么写?
function textboxfocus(textbox)
{    
    if(window.event.keyCode==13)
    {
       $parent=$(this).parent().parent();
       $parentNext=$parent.next();
    }
}

解决方案 »

  1.   

    $(":text",$(this).parent().parent().next());
      

  2.   

    我想要每个text触发onkeydown事件的时候,自动把焦点移动到下一个text就行
    $(":text",$(this).parent().parent().next().focus())吗???
      

  3.   

    $(":text").keydown(function(e){
        //if(e.keyCode == 13)
            $(this).next(":text").focus();
    })
      

  4.   

    $(":text").keydown(function(e){ 
        if(e.keyCode == 13) 
            $(this).next(":text").focus(); 
    })
    我把上述代码直接放在js里,运行页面直接出错啊。。Microsoft JScript 运行时错误: 缺少对象
      

  5.   

    更通用的不依赖于页面结构的做法是function textboxfocus(obj)
    {
    var texts = $(":text");
    $.each(texts,function(idx,text){
    if(text == obj){
    texts[idx+1].focus();
    return false;
    }
    });
    }