Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.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-通过父级输入focus()并查找嵌套元素类_Jquery_Html - Fatal编程技术网

Jquery-通过父级输入focus()并查找嵌套元素类

Jquery-通过父级输入focus()并查找嵌套元素类,jquery,html,Jquery,Html,我有这个html。使用JQuery如何在单击 我在想这样的事情: $('.mm-subopen').click(function () { //find this.class parent, parent (witch would be: <li class="img no-arrow join">) //and then trough: <li class="img no-arrow join"> find the input in same

我有这个html。使用JQuery如何在单击

  • 我在想这样的事情:

    $('.mm-subopen').click(function () {
        //find this.class parent, parent (witch would be:  <li class="img no-arrow join">)
        //and then trough: <li class="img no-arrow join"> find the input in same scope and get it focused
    });
    
    $('.mm子笔')。单击(函数(){
    //查找this.class parent,parent(将是:
  • ) //然后通过:
  • 在相同的范围内找到输入并使其集中 });

  • 任何帮助都将不胜感激

    您可以替换链接

    <a class="mm-subopen" href="#clickMe"></a>
    

    我想这就是你的想法

    $('.mm-subopen').click(function () {
        $(this).parents("li").find(":input").focus();
    });
    

    这里有一个

    我需要在js中完成,因为
    href=“#clickMe”
    在我的代码的许多其他部分都使用。Iv'e尝试了你的js解决方案,但不起作用。我的
    标记在加载文档时动态构建。这可能是个问题吗?是的,这可能是个问题。试试这个
    $(文档).on('click','.mm subopen',function(){$(this).closest('li').find('input').focus();})。奇怪,还是不起作用。我以为你最后一次送的人会修好的。你知道这里还有什么问题吗?有什么建议吗?嗯,不确定。你能用小提琴复制这个问题吗?顺便问一下,聊天输入必须是
    li
    元素,而不是
    div
    <label class="mm-subopen" for="studio123"></label>
    
    $('.mm-subopen').click(function () {
        $(this).closest('li').find('input').focus();
    });
    
    $('.mm-subopen').click(function () {
        $(this).parents("li").find(":input").focus();
    });