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?
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?
You can get it by html()
. It returns the html content (innerHTML) inside an element
Code
var h1Content = $('h1').html();
jQuery has a useful function for that: html()
:
var content = $('h1').html();