怎样用一个已有的jquery对象得到其他的子元素?

How could I get the sub element by using an existed jQuery object ?
已经有了#divTest的对象,怎样通过它来得到其他的元素?

    <!doctype html>
    <html lang="en">
    
    <head>
        <meta charset="utf-8">
        <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    
    <body>
    
        <div id="divTest">
            <input type="text" value="a" />
            <input id="next" type="text" value="b" />
            <input type="text" value="c" />
            <input type="text" title="d" value="d" />
            <input type="checkbox" title="e" />
    
        </div>
    
        <script>
            var myObj = $("#divTest");
            //How could I get the checkbox element by using 'myObj'?
            
            //解决办法:
            var titlevalue = myObj.children("input[type='checkbox']").attr("title");
        console.log(titlevalue);
            
        </script>
    
    </body>
    
    </html>
阅读 3.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题