Would like to use jQuery to:
- select any punctuation marks (meaning
.,;:'"“”‘’etc.) that occur directly before and after any links and then - wrap the punctuation marks in
spans.
Hence this:
<div id="mydiv">
Lorem ipsum
<a href="#">dolor sit amet</a>,
consectetur
“<a href="#">adipisicing elit</a>”.
</div>
to become this:
<div id="mydiv">
Lorem ipsum
<a href="#">dolor sit amet</a><span>,</span>
consectetur
<span>“</span><a href="#">adipisicing elit</a><span>”.</span>
</div>
(BTW, &ldquo and ” are quotation marks.)
The content in the div is not fixed. There may also be instances where there's more than one punctuation mark adjacent to a link (as in the above, ”. to become <span>”.</span>)
Would really appreciate any help!!
Sorta similar (but not quite) to this question with regards to selecting text nodes? http://stackoverflow.com/questions/2742223/using-jquery-how-to-modify-text-outside-of-tags/2742348#2742348