Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery选择所选列表中的输入<;tr>;_Jquery - Fatal编程技术网

jquery选择所选列表中的输入<;tr>;

jquery选择所选列表中的输入<;tr>;,jquery,Jquery,尝试在先前选择的tr内选择输入并向其添加焦点 以下是HTML: <div id="login" style="position:relative; display:none; top:0px; left:0px; right:0px; bottom:0px; text-align:center; vertical-align:middle; z-index:10;" class="trwhole"> <table width="100%" height="100%">

尝试在先前选择的tr内选择输入并向其添加焦点

以下是HTML:

<div id="login" style="position:relative; display:none; top:0px; left:0px; right:0px; bottom:0px; text-align:center; vertical-align:middle; z-index:10;" class="trwhole">
<table width="100%" height="100%">
    <tr width="100%" height="100%">
        <td width="100%" height="100%" style="vertical-align:middle; text-align:center;">
            <img src="images/MemorizeItWhite.png" z-index="10000" style="width:290px;">
            <table align="center" class="w290">
                <tr>
                    <td>
                        <div id="lerror" class="alert"></div>
                    </td>
                </tr>
                <tr>
                    <td align="left">Username:
                        <br>
                        <input autocorrect="off" autocapitalize="off" type="text" placeholder="username" id="username" style="" class="ui-corner-all w290">
                    </td>
                </tr>
                <tr>
                    <td align="left">Password:
                        <br>
                        <input type="password" placeholder="password" id="password" style="" class="ui-corner-all w290" onkeypress="if (event.keyCode==13){login();}">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" id="loginBt" onclick="login();" value="Log In" class="submit" style="width:85px;">
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</div>
不幸的是
$(evt.target).filter(“输入”).focus()
他没有这样做

我也试过了

$(this).filter('input').focus();
但是,也不能将焦点放在输入上

欢迎提出任何意见


谢谢

evt.target
指事件起源的元素,它可能不是
tr
元素。您可以在单击处理程序中使用
this
来引用
tr
元素

$('#login tr:has(input[placeholder]), #signup2 tr:has(input[placeholder])').on("touchstart", function (evt) {
    $(this).find("input").focus();
    evt.stopPropagation();
});

演示:

正如我在问题中提到的,我试过了,只是你用了双引号而不是单引号。我刚才试过,但还是没运气。@K'shin被认为是用find代替过滤器
$('#login tr:has(input[placeholder]), #signup2 tr:has(input[placeholder])').on("touchstart", function (evt) {
    $(this).find("input").focus();
    evt.stopPropagation();
});