How can this escape be achieved?

needs to be escaped to

    &ltp><img alt="" src="upfiles/54591303758197437.jpg" />

excuse me, how can I do this quickly with javascript, jquery?

Jun.10,2021

https://blog.csdn.net/wzygis/.

function htmlEncode(value){
  return $('<div>').text(value).html();
}

//HTML
function escapeHTMLString(str) {
    str = str.replace(/</g,'<');
    str = str.replace(/>/g,'>');
    return str;
}

//HTML
function escapeStringHTML(str) {
    str = str.replace(/</g,'<');
    str = str.replace(/>/g,'>');
    return str;
}

var str = '

<img alt="" src="upfiles/54591303758197437.jpg" />

'; var str1 = escapeHTMLString(str); console.log(str1); // &ltp><img alt="" src="upfiles/54591303758197437.jpg" />

var str2 = escapeStringHTML(str1); console.log(str2); //'

<img alt="" src="upfiles/54591303758197437.jpg" />

'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eadc46-5cf9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eadc46-5cf9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?