how to read contents from $(this) selector and its children separately?
<div class="para">
<h1 class="hd">heading 1</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tincidunt pharetra est, quis facilisis purus elementum ut. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
</div>
I can read the contents of the <h1>separately using $(this).children(“h1”).text() but how do you read the content from the excluding <h1>?
thanks
You can get the content via a
.clone(), like this:You can give it a try here, all we’re doing is cloning the element, removing that
<h1>from the clone then getting the text out.