Replace &lt; with < and &gt; with > using jquery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

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

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.2.js"></script> 
  <script type="text/javascript">
    $(function(){/*from w ww  .j  a va  2  s  .  co  m*/
$('#test').each(function(){
    var $this = $(this);
    var t = $this.text();
    $this.html(t.replace('&lt','<').replace('&gt', '>'));
});
    });

      </script> 
 </head> 
 <body> 
  <div id="test">
    &lt;span style="font-weight:bold;"&amp;gtHello world!&lt;span&gt; 
  </div>  
 </body>
</html>

Related Tutorials