Sometimes we get data from the server which contains HTML elements such as div span or internal CSS. We can either remove or parse those tags using backend language or we can achieve the same with javascript replace() function. Using Regex in javascript we can remove any HLMT tag from the string. following is the code to remove the HMLT tags from string.
var str = "<div>Hello, <h2>atcodex</h2></div>"; var textData = str.replace(/<\/?[^>]+(>|$)/g, "");