Check Your Internet Speed

jQuery code 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.
1console.log($('#dvTest').text());
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.
1: var str = '<div>Sample <u>HTML</u> <b>Text</b> with <i>tags</i></div>';
2: console.log($(str).text());

Source : jquerybyexample.blogspot.com

0 comments:

Post a Comment

Websites Resources | Blogging | Technology News | Softwares - i Developments