Looking at “In jQuery, want to remove all HTML inside of a div“, I got going in the right direction to what I’m looking for:
I have a textarea similar to the following:
<textarea id="inputPane" cols="80" rows="40" class="pane" style="height:300px;">
<table><tr><td>
<b>Since your service bureau</b>, xxx is not certified
by our company for xyz, your company will need to complete
more testing as part of the process.
</td></tr></table>
</textarea>
Using this code from the URL listed above, I’m able to remove all whitespace apparently, but am unable to remove the actual HTML tags: <b></b>, <table>, etc.
jQuery.fn.stripTags = function()
{ return this.replaceWith( this.html().replace(/<\/?[^>]+>/gi, '') ); };
What is this part saying?
/<\/?[^>]+>/gi
I think it reads:
- remove this character
< - and remove this character
> - and replace with nothing.
Although this is not what it is doing in my code. It seems to strip all the whitespace from the DIV I put it on.
What is the gi part?
And, would you have a good solution to remove HTML tags from a wmd-editor textarea when the HTML displayed is coming from a database?
I use the following script to remove html tags from a string-
not exactly sure but i think
/gipart indicates global replace like instring.replacein JavaScript.