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,262
  • 11
  • 21
tuna
  • 6,211
  • 11
  • 43
  • 63
  • 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
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
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,580
  • 1
  • 17
  • 29