Thursday, 15 July 2010

javascript - Is this an efficient way to convert HTML to text using jQuery? -


I'm trying to convert HTML to plain text, is it efficient? Am I missing something?

  txt = $ ("body"). ("Script, Noscript, Style, Hidden"). Remove (). End (). Text ();  

Thanks!

HTML is text.

Edit Try it ...

  // Get the existing body text html html = $ ("body"). (); // Create a new jQuery object outside body text and delete the desired elements. Var text = $ (html) .remove ("script, noscript, style, hidden"). Text ();  

No comments:

Post a Comment