Reputation: 2961
In the below code I would like to put a variable to the text within the div
but NOT whats inside the p
tag:
<div class="review-content merchant-review-content">
I want to grab this text
<p class="review-rating">
From a cool person
- My Date goes here
-
A Review
</p>
<div></div>
</div>
Additionally I would like to only pull the first 250 characters of it, if thats possible!
Upvotes: 3
Views: 991
Reputation: 207901
Try this snippet:
$("div.review-content").clone().children('p').remove().end().html().substring(0,250);
Upvotes: 1
Reputation: 9167
I found this tutorial: http://viralpatel.net/blogs/2011/02/jquery-get-text-element-without-child-element.html
Final jsFiddle: http://jsfiddle.net/w9N8N/3/
Upvotes: 3