2016-09-16 94 views
-4

我在使用jquery訪問子項時遇到了一些問題。 我有一個HTML這樣jquery在div中找到一個元素

<div id="wrapper"> 
    <div> 
    <div> 
     <table id="customer"> 
     </table> 
    </div> 
    </div> 
</div> 

我有這個jQuery這樣

var parentDiv = $('#wrapper'); 
var table= parentDiv.html(); 
console.log(table); 

輸出

<div> 
     <div> 
      <table id="customer"> 
      </table> 
     </div> 
     </div> 
table = $(table); //jquery object 
//i want the table customer of this object 

我要的是讓客戶表。我怎樣才能使用var表? .each()僅提取div以及.find()。

像這樣

$(innerHtml).each(); //or whatever function i can use to get the table 
+2

使用'$( '#客戶')'沒有必要找 – guradio

+0

耶,我可以這樣做,但我想要的是讓innerHtml的表。 – n4mi

+0

哪個div內部的html? –

回答

0

試試這個:

$('#customer').parent('div').html(); 
相關問題