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

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 :: javascript check date greater than today 
Javascript :: jsonobject gradle dependency 
Javascript :: nodejs create buffer from string 
Javascript :: check if number is negative javascript 
Javascript :: change list of objects to list js 
Javascript :: javascript object total 
Javascript :: array sort by alphabetical javascript 
Javascript :: sort array of objects javascript by value 
Javascript :: javascript location redirect 
Javascript :: js navigate to another page 
Javascript :: redirect to different page in javascript 
Javascript :: event handling in react documentation 
Javascript :: array.foreach 
Javascript :: react style ternary operator 
Javascript :: install json-server 
Javascript :: javascript for loops in vs of 
Javascript :: how to access model data in jsp spring mvc 
Javascript :: javascript copy an array 
Javascript :: how to add font family in material ui 
Javascript :: play audio in javascript 
Javascript :: js decode base64 
Javascript :: js get childrens 
Javascript :: json data doesn show on console 
Javascript :: round number 2 decimal places javascript 
Javascript :: gulp del 
Javascript :: create phone number javascript 
Javascript :: asp.net core 3.1 convert system.collections.generic.list`1[system.string] to javascript 
Javascript :: execute JS code after pressing space bar 
Javascript :: js cypress div text 
Javascript :: return index of array with function in array angular 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =