I have this line of code:
var newmsg = $('<div class="message msg_owner">' +
"<span class='msg_date'>"+dateFormat(timesp)+
"</span><span class='msg_seperator'> | </span><span class='msg_name'>" +
pseudo + '</span> : <span class="msg"></span></div>');
newmsg.find(".msg").text(replaceEmoticons(msg));
$("#chatEntries").append(newmsg);
Which basically creates divs or classes, then finds class named .msg and inserts text into it. replaceEmoticons(msg); is a function that finds all character sets of smileys (:D, :), :(, etc...) and converts them into something like:
<img src='http://example.com/public/images/smileys/laugh.png' id='chat_smls'/>
So I end up having message like:
Original:
Hello how are you? :)
It becomes:
Hello how are you? <img src='http://example.com/public/images/smileys/happy.png' id='chat_smls'/>
However, after the line:
newmsg.find(".msg").text(replaceEmoticons(msg));
That returns the code as text and in chat window it literally appears as the html img tag with all its attributes. From my understanding this is because of .text? If so, how can I fix it to strip all JS and other tags that may cause problems but leave that img?