javascript string replace &lt; into <


Hey all, I basically output content into a div like this using jquery:

var text = $("#edit").val();
$("#output").text(text);

But I want to turn "&lt;" and "&gt;" into "<" and ">".

text.replace(/&lt;/,"<"); doesn't seem to be working for me...

Any ideas? Many thanks


Answers:


Simple.

var needToConvert = 'But I want to turn "&lt;" and "&gt;" into "<" and ">".';

var convert = function(convert){
    return $("<span />", { html: convert }).text();
    //return document.createElement("span").innerText;
};

alert(convert(needToConvert));