javascript 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, "'");
}function escapeHtml(str) {
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
Also in HTML:
- html reorder list aaccording
- img tag
- ionic badge
- bootstrap 3 table
- how do i make a line in html
- how to set a var in js to be a download
- nav bar activate in jinja
- colspan tag html
- selenium python get innerhtml
- ionic range
- how to make navigation bar in html
- html table
- salesforce aura input checkbox
- linking external pages html
- buton html href
- results.html
- how to start a html file
- center group of html tags
- javascript remove html from text
- how to create a search box with html
- js form default value
- html to pug
- how to disable zoom in html page on different screen resolutions
- ionic color