- Sold between 250 000 and 1 000 000 dollars
- Won a Competition
- Author was Featured
- Item was Featured
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Europe
- Bought between 10 and 49 items
Hey,
How can I select “text” in the following code and wrap it in a “span” tag?
<div class="wrap"> This text should be selected and wrapped in a span <span class="span_class_name">Another content</span> </div>
Thanks guys!
May this helps you: http://stackoverflow.com/questions/926580/find-text-string-using-jquery ?
- Attended a Community Meetup
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Contributed a Tutorial to a Tuts+ Site
- Exclusive Author
- Has been a member for 3-4 years
- Interviewed on the Envato Notes blog
Use the .text() function.
var textsample = $(' div.wrap ').text();
textsample = "<span>" + textsample + "</span>";
// Clear contents of wrap div then add the text again.
$(' div.wrap ').html("").append(textsample);
I think this will work.
I think he’s not gonna have that exact sentence every time 
@mixey – This was a tough one, thank you for this little challenge
Here you go:
$('.wrap').each(function(){
$(this.childNodes).filter(function(index) {
if(this.nodeType === 3 && this.nodeValue != ''){ return true; }
}).wrap('<span>');
});
</span>
Edit: Stupid forum eating my code
Gimme a sec.
Here you go http://pastie.org/1579886
- Sold between 250 000 and 1 000 000 dollars
- Won a Competition
- Author was Featured
- Item was Featured
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Europe
- Bought between 10 and 49 items
Thanks to everyone and especially to Boba.
That did the trick!
mixey said
Thanks to everyone and especially to Boba. That did the trick!
You’re welcome 
- Envato Staff
- Reviewer
- Community Moderator
- Venezuela
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Microlancer Beta Tester
- Sold between 10 000 and 50 000 dollars
- Exclusive Author
This is why I effin’ love ThemeForest. 
