Answers for "jquery sanitize html"

1

jquery escape html string

function escapeHtml(str) {
    return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
}
Posted by: Guest on July-31-2019
0

jquery escape html string

//escaping HTML with jquery
var dangerousHTML = "<script>alert('Badabing Baby!');</script>";
$("#myElementID").text(dangerousHTML); //.text() function will escape and display text


//Alternatively, here is plain Javascript escape function
function escapeHtml(str) {
    return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
Posted by: Guest on July-31-2019
0

jquery sanitize html

<p><span style="font-family: Helvetica; font-size: 12px;">1.ô¸æê¿ÃȤáÃûäüµÃ·½·¨£»</span></p>
Posted by: Guest on September-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language