How To Replace &lt; with < and &gt; with > using jquery

Please try this

.replace(/&lt;/g, '<').replace(/&gt;/g, '>') 

to replace these characters globally. I tried this and works like a charm :)


I have different solution then the conventional, and it will be applied to decode/encode html

Decode

var encodedString = "&lt;Hello&gt;";
var decodedText = $("<p/>").html(encodedString).text(); 
/* this decodedText will give you "<hello>" this string */

Encode

var normalString = "<Hello>";
var enocodedText = $("<p/>").text(normalString).html();
/* this encodedText will give you "&lt;Hello&gt;" this string

The simplest thing to do would be

$('#test').each(function(){
    var $this = $(this);
    var t = $this.text();
    $this.html(t.replace('&lt','<').replace('&gt', '>'));
});

working edit/jsfiddle by Jared Farrish