Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js escape html

function escapeHtml(text) {
  return text
      .replace(/&/g, "&")
      .replace(/</g, "<")
      .replace(/>/g, ">")
      .replace(/"/g, """)
      .replace(/'/g, "'");
}
Comment

html escape function javascript

function escapeHTML(text) {  
    var replacements= {"<": "&lt;", ">": "&gt;","&": "&amp;", """: "&quot;"};                      
    return text.replace(/[<>&"]/g, function(character) {  
        return replacements[character];  
    }); 
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: vue toggle boolean on click 
Javascript :: momentjs german date format 
Javascript :: countdown timer with moment js 
Javascript :: img src to file javascript 
Javascript :: react native vector icons 
Javascript :: js loop through object keys 
Javascript :: http node 
Javascript :: strpos in javascript 
Javascript :: javascript create object key from variable 
Javascript :: mongoBD increment 
Javascript :: javascript how to take off a decimal 
Javascript :: javaScript Math.log10() Method 
Javascript :: remove element from array lodash 
Javascript :: antd react native 
Javascript :: Disabale Back History On Browsers JavaScript Jquery 
Javascript :: javascript default parameters 
Javascript :: html to pdf javascript 
Javascript :: mongodb unwind 
Javascript :: countdown javascript 
Javascript :: ReactDOMServer import 
Javascript :: how to check checkbox using jquery 
Javascript :: user icon discord js 
Javascript :: string interpolation in javascript 
Javascript :: foreach modify array javascript 
Javascript :: react conditional array item 
Javascript :: react native navigation remove top header screen 
Javascript :: how to display image before upload in jhtml 
Javascript :: json search javascript 
Javascript :: check if a word exists in dictionary javascript 
Javascript :: .env.development.local 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =