Need a function to remove HTML formating...

M

mblocks2

Does anyone has a function that will remove all HTML tags in some
string?

like

function removeFormating(str)
 
N

Noah Sussman

Does anyone has a function that will remove all HTML tags in some
string?

like

function removeFormating(str)

In general, this should work:

var myString = '<b>some</b> <a href="foo.html">text</a>';
myString = myString.replace(/<[^>]*>/g, '');
alert(myString); //result is 'some text'

so you want something like this:

function removeFormatting(str) {
return str.replace(/<[^>]*>/g, '');
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top