-4

I've got this html:

<h1>
   <span>
       <span>
          Sony
       </span>
   </span>

   Televisies
</h1>

How do I get all content within the h1 so with the span html as as wel?

Jenssen
  • 1,801
  • 4
  • 38
  • 72

2 Answers2

2

You can get it by html(). It returns the html content (innerHTML) inside an element

Code

var h1Content = $('h1').html();

Fiddle demo

Ullas
  • 11,450
  • 4
  • 33
  • 50
1

jQuery has a useful function for that: html():

var content = $('h1').html();
Matt Spinks
  • 6,380
  • 3
  • 28
  • 47