Doesn't $().text(); automatically do this?

So:

var text = $(html).text();

Would solve your problem, I think.

- jake

On 9/14/07, Stosh <[EMAIL PROTECTED]> wrote:
>
>
> In Prototype there is a method called stripTags(), it's source looks
> like:
>
> stripTags: function() {
>     return this.replace(/<\/?[^>]+>/gi, '');
> }
>
> To do it the jQuery way, I might consider doing something like this...
>
> jQuery.fn.stripTags = function() {
>         return this.replaceWith( this.html().replace(/<\/?[^>]+>/gi, '')
> );
> };
>
> Hope this helps, Pax.
>
> - Stan
>
>
>
> On Sep 11, 11:08 am, AnandG <[EMAIL PROTECTED]> wrote:
> > I retrieve a lot of strings from a JSON file. These strings can contain
> HTML
> > tags.
> >
> > I would like to show the strings (for example a description of a
> product)
> > but with a limit on the number of characters.
> >
> > So I have to count the number of characters and I would like to set a
> limit
> > to 200 characters. But I want to exclude the
> > characters of the HTML tags. The easiest method seems to me to strip
> HTML
> > tags in the strings.
> >
> > I have searched in this forum and found some posts that deal with
> stripping
> > out HTML tags:
> >
> > http://www.nabble.com/Strip-a-href-links-from-a-div-tf4372556s15494.h...
> > Strip a href links from a div
> >
> > http://www.nabble.com/stripping-out-tags...-tf2583359s15494.html#a720...
> > Stripping out tags
> >
> > But they all require that you send a HTML tag as a parameter. But that's
> > difficult if i'm not sure which HTML tag is going to be used.
> >
> > --
> > View this message in context:
> http://www.nabble.com/Strip-out-HTML-tags-tf4421390s15494.html#a12611168
> > Sent from the JQuery mailing list archive at Nabble.com.
>
>

Reply via email to