1

I have the following html template. I want to get the first person_line div's content includes the person_line div.

<div class=​"person_row">​
    <div class=​"row-fluid person_line">​
        <div class=​"span4">​…​</div>​
        <div class=​"span8">​…​</div>​
        <div class=​"clearfix">​</div>​
    </div>​
    <div class=​"row-fluid person_line">​
        <div class=​"span4">​…​</div>​
        <div class=​"span8">​…​</div>​
        <div class=​"clearfix">​</div>​
    </div>​
</div>​

I tried $($('.person_line')[0]).html() but that does not include the <div class=​"row-fluid person_line">. Any ideas ? How can i get the content of person_line as html which includes the upper div.

OptimizedQuery
  • 1,266
  • 11
  • 21
tuna
  • 5,781
  • 11
  • 39
  • 61
  • possible duplicate of [Get selected element's outer HTML](http://stackoverflow.com/questions/2419749/get-selected-elements-outer-html) – andyb Jun 11 '13 at 12:50

2 Answers2

5

try using outerHTML -

$('.person_line')[0].outerHTML
Mohammad Adil
  • 44,013
  • 17
  • 87
  • 109
0

Try this

$(".person_line").eq(0).html();

more over if you want to get the children of the person_row

childArray = $(".person_row").find(".person_line");

Hope this might help.

Akhilesh Sharma
  • 1,518
  • 1
  • 16
  • 26