-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,656
  • 4
  • 28
  • 67

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,201
  • 4
  • 31
  • 47
1

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

var content = $('h1').html();
Matt Spinks
  • 5,910
  • 1
  • 21
  • 45