I am just trying to replace html brackets with their ascii equivalent. Particularly < for < and > for > for code inside a pre tag.
There must be a very simple script to do this but I can`t find it.
Something along the lines of the code below except something that works.
$('.code').each(function() {
var $this = $(this);
var t = $this.html();
$this.html(t.replace('/</g','<').replace('/>/g','>'));
});
Any help would be much appreciated.
You should do validation/replacing of
<and>server-side using PHP etc. as people can easily disable JavaScript and evade validation that is client-side. Client-side validation is like saying for a stranger to look after your wallet. Sometimes the stranger will be a nice person and not open it. Sometimes they may be a thief.Anyway, here is a PHP example: