callum.bennett
callum.bennett

Reputation: 686

get entire contents of a div

var thisWish = $(#div1).children('p,blockquote,.name').html();

<div id="1">
   <p>Hello</p>
   <blockquote> my name is </blockquote>
   <p class="name">Callum</p>
</div>

How can i put the entire contents of a div into a variable? I dont justwant the html of each variable, i need the elements aswell, so basically i need

thisWish = <p>Hello</p>
       <blockquote> my name is </blockquote>
       <p class="name">Callum</p>

Thanks

Upvotes: 0

Views: 271

Answers (2)

Vivek
Vivek

Reputation: 11028

try this...

 thisWish = $('div#1').html()

Upvotes: 0

Jochem
Jochem

Reputation: 2994

This should work:

thisWish = $('div#1').html()

Upvotes: 4

Related Questions