I'm trying to grab the entire html of .spec including the <ul class="spec"></ul> but using the below code it grabs only the children of .spec
HTML
<div class="single-vacancy">
<p class="title"><strong>This title</strong></p>
<span class="read-more">View Vacancy</span>
<ul class="spec">
<li>List</li>
<li>List</li>
<li>List</li>
</ul>
</div>
jQuery
$('.read-more').click(function() {
var role = $(this).next('.spec').html();
});
Or the jquery way:
var role = $(this).next('.spec').prop('outerHTML');
Using html() returns only the content HTML (innerHTML) not the outer HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With