Muhammad Shahzad
Muhammad Shahzad

Reputation: 9652

I want to get all content of a div using jquery

I want to get all content of a div using jquery.

<div id="load_template_data" style="border:1px solid #000000;  width:100%;">

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">

  <head>
  ...my stuff
  </head>
  <body>
  ..my other stuff
  </body>
  </html>

  </div>

but when I use jquery function

 `var editor_data = $('#load_template_data').html();
    alert(editor_data);`

 'alert(editor_data);'  

retrun me only div tags,means only html, not return <head></head> <body></body></html>

so I use `var editor_data = $("#load_template_data").contents();

    alert(editor_data);`

but this return [object Object] I want to get all data from this div.perhaps I am missing anything.

Upvotes: 1

Views: 1431

Answers (1)

PonrajPaul
PonrajPaul

Reputation: 174

These are content related tags. So you can get this with data

<table>
<tr>
<td>
<div>
<span>
<a>
<link>
<img>

But these are HTML syntax tags. So you can't get this tags

<!DOCTYPE>
 <HTML>
 <head>
 <body>

Upvotes: 1

Related Questions