JSFiddle - React, Tailwind, and code Playground

by Vitaliy

HTML

<input type="text" id="id" placeholder="id">
<textarea name="" id="html" cols="30" rows="10" placeholder="html"></textarea>
<div id="el1">some div</div>
<a href="#" id="el2">Link</a>

CSS

input, textarea{
  display:block;
  width:300px;
  box-sizing:border-box;
  margin: 0 0 10px 0;
}

JavaScript

var $id = $('#id'),
		$html = $('#html');
$('body').on('click', function(e){
	if(e.target.id == $id.val()){
  	e.preventDefault();
  	$(e.target).replaceWith($html.val());
  }
});