(function( $ ) {
$.fn.htmlCodes = function(){
var $this = this;
var body = this.html();
body = body.replace(':)', '☺').replace('<3', '♥');
this.html(body);
};
})( jQuery );
I wrote this JQuery plugin so that it would change smiley faces to the smiley face entity. (and heart)
However, the heart doesn’t work! For some reason the smiley works but heart doesn’t.
Works if you do this…
DEMO: http://jsfiddle.net/ZdJh5/
The
.html()is giving you the HTML character code for the<symbol.