How could I get the sub element by using an existed jQuery object ?已經有了#divTest的對象,怎樣通過它來得到其他的元素? <!doctype html> <html> <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>
怎樣用一個已有的jquery對象得到其他的子元素?
慕容森
2018-09-05 09:19:40