javascript - Replacing nesting of text tags such as with in an HTML element? -
I have an internal HTML division which is very much like:
& lt; B & gt; First & lt; Span class = "red" & gt; From & lt; / Span & gt; & Lt; / B & gt; & Lt; Span class = "red" & gt; For the third position & lt; / Span & gt; Urth fift & lt; Span class = "large" & gt; H sixth and lieutenant; Span & gt; This markup may contain text adatting tags because it is the output of the text-editing library.
For whatever I am working on, I need to remove any nesting victim. Therefore, ideally, the above markup string should be:
To give some context, the markup Wysihtml5 text editor is produced at the top, which is very useful, but I need a markup so that the markup is required to be second enabled
Try it out:
$ (document) .ready (function () { $ ('B'). (Function () {var text = $ (this). Html (); $ (this) .replaceWith ('& lt; span style = "font-weight: bold; color: red" & gt; '+ text +' & lt; / span & gt; ';);});}); Object:
Comments
Post a Comment