<div id="maintest"> <div class="t"> <div>title</div> <div class="ch"> <input type="text name="input1" value="" id="i1"> </div> <div class="t"> <div>sub title</div> <div class="ch"> <input type="text name="input2" value="" id="i2"> </div> </div> </div> <div class="t"> <div>title2</div> <div class="ch"> <input type="text name="input2" value="" id="i2"> </div> </div> </div>
// $('#maintest div.t').not('.no div').each(function (index,element) { // 只有第一個 // $("#maintest").find("div.t").each(function (index,element) { // 會找到三個 $("#maintest").children("div.t").each(function (index,element) { // 會找到2個 console.log(" L==>index"+index+" ==> " + $(this).html() ); });