2016-09-16 110 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();