I made this html preview, it works fine for my purpose however the first element is appearing as text, and this is a bad result, I understand very little of jquery and javascript, I'm starting to study, I'd like to understand the is going wrong.
If you put <div></div>
the opening tag appears: <div>
, but only the first, the rest of the code does not appear
Run the snippet to better understand
function showPreview()
{
var value = $('#copy').val().trim();
value = value.replace("<", "<");
value = value.replace(">", ">");
$('#preview').html(value);
}
textarea {
resize:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><textareaid="copy" onInput="showPreview();"><div><img src='https://i.imgur.com/FfInIT9.jpg' width='100'/></div>
</textarea>
<br>
<div id="preview"/>