我获取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();
}
}
<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();
}
}
$(":text",$(this).parent().parent().next().focus())吗???
//if(e.keyCode == 13)
$(this).next(":text").focus();
})
if(e.keyCode == 13)
$(this).next(":text").focus();
})
我把上述代码直接放在js里,运行页面直接出错啊。。Microsoft JScript 运行时错误: 缺少对象
{
var texts = $(":text");
$.each(texts,function(idx,text){
if(text == obj){
texts[idx+1].focus();
return false;
}
});
}