Как разместить HTML-код без рендеринга браузера
I'm currently working on my school project and am to build a forum for the project,But right now am facing this problem where i want users to be able to post their html source code as it works in this forum,but the problem is that the code runs or scatters my design when retrieve from my DB.I try using repalce() in jquery but i could only replace < with < but i want a function to be able to replace others such as >,",' and & so my question is how can i write this function.
the below code work to replace the < but when i try including >,",' and & in the function it will stop work how can i make it work please someone should help me out.
Что я уже пробовал:
function convert(div){ var str = $(div).html(); var str2 = str.replace(/</g,"<"); var sta = $(div).html(str2); return sta; }