I have the following HTML-code:
<div id="Test">
My selected Link
<a href="link1.html">My Link 1</a>
<a href="link2.html">My Link 2</a>
</div>
I need to find the text string inside:
<div id="Test"></div>
and wrap it with a tag. It will always be only one text string inside
<div id="Test"></div>
but the text will have different locations in the code, for example:
<div id="Test">
<a href="link1.html">My Link 1</a> Another Selected Link
<a href="link2.html">My Link 2</a>
</div>
The result I’m looking for is something like this:
<div id="Test">
<a href="link1.html">My Link 1</a>
<h2>Another Selected Link</h2>
<a href="link2.html">My Link 2</a>
</div>
So to sum up: find the only text string inside the div (but not in the children tags) and wrap it with a tag.
Hope this helps in your specific case
jsBin demo
http://api.jquery.com/not-selector/
http://api.jquery.com/contents/
http://api.jquery.com/wrap/