jQuery: How to Strip/Remove HTML tags

In this short post, find jQuery code to strip/remove HTML tags. To remove HTML tags, use text() function which returns only the text content and ignores the HTML portion.


You can also strip/remove HTML tags from any variable as well as text() is jQuery function, so the variable needs to be converted into a jQuery object so that text() can be used.

var str = '<div>Sample <u>HTML</u> <b>Text</b> with <i>tags</i></div>';

Feel free to contact me for any help related to jQuery, I will gladly help you.

Responsive Menu
Add more content here...