jquery 如何用this获取子对象里的某个属性的对象
我想写一个js用于获取某个对象
现在有一个input 在一个table里面
<table id="tblGrid2">
<input tabindex=12/>
<input tabindex=13/>
</table>
如何通过this获取<input tabindex=13/>这个对象。
类似如下,不过如下这个是不行的。
$(":input[tabindex=" + tabIndex + "]", this).focus();
this 是table的对象。
[解决办法]
this关键字在对象内部使用才有意义。
var tabIndex = 13;$(":input[tabindex='" + tabIndex + "']", $("#tblGrid2")).focus();
[解决办法]
this在这里不行的楼主,测试了如下可行
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改对象原型</title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
$(":input[tabindex='13']", $("#tblGrid2")).focus();
}
</script>
</head>
<body>
<table id="tblGrid2">
<input tabindex=12 />
<input tabindex=13/>
</table>
</body>
</html>
</body>
</html>
<script type="text/javascript">
window.onload=function(){
$(":input[tabindex='13']", $("#tblGrid2")).focus();
}
</script>