<span id="subscription-toggle" class="list:subscription">
| <!-- I want to surround this with a div with a class -->
<span class="" id="subscribe-77" style="">
<a class="dim:subscription-toggle:subscribe-77:is-subscribed" href="http://localhost/taiwantalk2/topic/topic-with-two-tags-topic-with-two-tags-topic-with-two-tags/?action=bbp_subscribe&topic_id=77&_wpnonce=25988e5dac">Subscribe</a>
</span>
</span>
So this should be the final result:
<span id="subscription-toggle" class="list:subscription">
<div class="hide-this"> | </div>
<span class="" id="subscribe-77" style="">
<a class="dim:subscription-toggle:subscribe-77:is-subscribed" href="http://localhost/taiwantalk2/topic/topic-with-two-tags-topic-with-two-tags-topic-with-two-tags/?action=bbp_subscribe&topic_id=77&_wpnonce=25988e5dac">Subscribe</a>
</span>
</span>
If the text node you wish to wrap your
divaround is the only text node (i.e. it’s the only text insidesubscription-togglethat is not inside another element) then you can do this:You can see an example here.
Alternatively, if there are multiple text nodes in the
span, and you only want to wrap|characters, replace the body of thefilterfunction with this line:return $(this).text().indexOf("|") != -1;You can see an example of that one working here.