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 :: react bind function to component 
Javascript :: javascript remove empty array 
Javascript :: json array to string in postgresql 
Javascript :: login page link shopify 
Javascript :: react useeffect 
Javascript :: js is array 
Javascript :: how to change css style on click 
Javascript :: emoji mart npm 
Javascript :: how to add up all numbers in an array 
Javascript :: convert long date to short date javascript 
Javascript :: typeof array javascript 
Javascript :: how to remove duplicate array object in javascript 
Javascript :: javascript remove final newline from string 
Javascript :: json stringify pretty 
Javascript :: javascript create range with a loop 
Javascript :: javascript array flat 
Javascript :: call laravel route js 
Javascript :: react not getting img by src 
Javascript :: js number to scientific notation 
Javascript :: useeffect with cleanup 
Javascript :: jquery add multiple classes 
Javascript :: datepicker auto close 
Javascript :: how to change style of an element using javascript 
Javascript :: factorialization in javascript 
Javascript :: upload and read json file javascript 
Javascript :: javascript array push middle 
Javascript :: reverse string js 
Javascript :: export default new class in es6 
Javascript :: javascript on keypu 
Javascript :: discord.js ban command 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =