I have an extract html file from a comment system I have to use that looks like this:
<div>Plz say my name&#128516;&#9996;&#127995;</div>
<div>Dose Amelia like donuts &#127849;&#127849;</div>
Obviously the part to note is all the emoji. I then pull that HTML file in using
var questionsfile = "comments.inc";
$.get(questionsfile, function(response) {
$(".noquestions").replaceWith(response);
});
I used .replace()
to convert it back to ✌
but it now just outputs it as plain text. How do I make it so that the response
output contains ✌🍩?
You need to replace its text
as its html
, check the demo below
var str = `<div>Plz say my name&#128516;&#9996;&#127995;</div> <div>Dose Amelia like donuts &#127849;&#127849;</div>`; var $str = $( str ); $str.find( "div" ).each( function(){ //iterate each div $(this).text( $(this).html() ); //replace text with html }) $(".noquestions").replaceWith( $str );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="noquestions-wrapper"> <div class="noquestions"> assasd </div> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.