JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<p>
Given are strings in an imout field like these, representing an emoji: <strong>[e-1f60e]</strong> </p>
<p>
Now I want to display them "live" as emojis, instead of only the code: 😎
</p>
<input id="blub" type="text" name="test" value="[e-1f60e]">
<input type="submit" value="Test 1" id="tauschen">
<br>
<input id="blub2" type="text" name="test" value="[e-1f60e]">
<input type="submit" value="Test 2" id="tauschen2">
JavaScript
$("#tauschen").click(function() {
$('#blub').val(function(index, value) {
return value.replace('[e-1f60e]', '😎'); // Doesn't work
});
});
$("#tauschen2").click(function() {
$('#blub2').val(function(index, value) {
return value.replace('[e-1f60e]', '😎'); // Works - but how to convert the given string to an emoji?!
});
});