JSFiddle - React, Tailwind, and code Playground

by stodolaj

HTML

<html>
    <body>
        <textarea id="input" rows="5" cols="50"><text>Lorem <foo>ipsum</foo> dolor sit amet.</text></textarea>
        <textarea id="output" rows="5" cols="50">
        </textarea>
        <div><button>Do it</button></div>
    </body>
</html>

JavaScript

$(function() {
    $("button").click(function() {
      var xml = $("#input").text();
      var $xml = $("<x></x>").append(xml);
    
      $xml.find("foo").replaceWith(function(){
        return "<b>" + $(this).text() + "</b>";
      })
        
      $("#output").html( $xml.html() );
    });
});