Reputation: 66
Site have this kind of structure
<div class="main">
hello world<br />
againg hello world<br />
<h3>some text</h3>
<ul>
<li>again text</li>
<li>again text</li>
</ul>
</div>
Now, i want take text with all br tags or with same html structure beetween class main and h3. i used to .prevUntil() but can't do anything
Upvotes: 0
Views: 72
Reputation: 30135
You could try something like this:
var html = $('#main').clone().find('>*').remove().html();
This creates a clone of your #main div and removes all child elements, leaving only the text.
Though it would be better to wrap that text in another element like a p
.
Upvotes: 2