jquery - how to change my innerHTML from < to &lt; -


i'm trying access inner html source , want change < , > &lt; , &gt; respectively,though went run code browser did render want when edit source code see &lt;div&gt; instead of <div> while on screen see <div>, want code posted on site.

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

the above stop browser rendering code html , display code on screen in source code instead of <div> shows <div> if


Comments

Popular posts from this blog

unix - grep command not match start of new line with another regex -

sql - calculate weighted average for each day and id based on time intervals in PostgreSQL -

Sort a complex associative array in PHP -