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 :: get attribute href 
Javascript :: angular download blob pdf 
Javascript :: nextjs socket.io 
Javascript :: how to define emojis from your server in discord.js 
Javascript :: concurrently script 
Javascript :: mongoose connect to URL of atals 
Javascript :: js clamp 
Javascript :: canada postal code regex 
Javascript :: redirect using javascript 
Javascript :: redirect to another page using javascript 
Javascript :: javascript redirect another page 
Javascript :: react form on submit 
Javascript :: get class count in jquery 
Javascript :: node redirection 
Javascript :: json server 
Javascript :: if statement es6 
Javascript :: datepicker get selected date 
Javascript :: json parse array local storage 
Javascript :: scroll to bottom of div javascript 
Javascript :: play music from file js 
Javascript :: next js fallback 
Javascript :: push element to array to first place js 
Javascript :: javascript get local storage 
Javascript :: update param in url jquery 
Javascript :: check if object values are empty 
Javascript :: javascript last element in array 
Javascript :: pass an array to javascript in asp net core list 
Javascript :: force page to reload on back button 
Javascript :: next router push state 
Javascript :: usedispatch 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =