Total Pageviews

6/10/2013

Remove HTML Tags from a string




Recently I required to remove HTML tags from html page. For that I have used following function which removes all HTML tags.

Source Code

Paste Your Source code into designated area.For Example.
    
    <p><strong>Input code:</strong>
        (<em>Note: Processing is done on the "input-code" id</em>)</p>
    <pre>
    <code id="input-code">    
    <h2>About</h2>
    <p>Here you will find post about how to remove HTML tag from a string using
    javascript.<p>
    <p><a href="/about">Read more</a></p>

External File

Create RemoveHTML.js external file and paste following code.

         function removeHTMLTagFromString()
         {
             if (document.getElementById && document.getElementById("input-code"))
             {
                  var strHtmlCode = document.getElementById("input-code").innerHTML;

                 /* It replaces escaped brackets with real ones,
                  i.e. < is replaced with < and > is replaced with > */

                  strHtmlCode = strHtmlCode.replace(/&(lt|gt);/g,
                  function(strMatch, p1)
                  {
                     return (p1 == "lt") ? "<" : ">";
                   });
                   var strTagStrippedText = strHtmlCode.replace(/<\/?[^>]+(>|$)/g, "");    

                   alert("Output text:\n" + strTagStrippedText);
            }
         }

Head

import javascript file into head section of HTML document.
    <script type="text/javascript" src="removeHTML.js"></script>

Body

Paste the code into BODY section, which HTML Tag you want to remove in HTML document.
    <p><strong>Input code: </strong>( <em>Note: Processing is done on   the "input-code" id </em>)</p>
    <pre> 
    <code id="input-code"> 
    <h2>About</h2>
    <p>Here you will find post about how to remove HTML tag from a string using
    javascript.<p>
    <p><a href="/about">Read more </a></p>
    </code> 
    </pre>
   
    <a href="#" onclick="removeHTMLTagFromString(); return false;">
    »Click to remove all HTML  tags from the input code </a>.


35 comments:

maheswari said...

Really a great post. Thanks for sharing this unique information with us. I get admired by reading your post. Keep on Blogging
Datawarehousing Training in Chennai

essay writing said...

Remowing HTML tags from the string is not a difficult thing to do.

sivanesan said...

The best thing is that your blog really informative thanks for your great information!
erp in chennai

Simmi Sharma said...

Cinematographer in jaipur
Great post and very helpful for me.Thanks for share this post

Sasha said...

Escorts service in jaipur

good knowledge for your post thanks

sapanchoudhary said...

The article shares very meaningful information, at least for me. Thanks for sharing, my friend! Please visit my website hope you enjoy it

jaipur call girls service
jaipur call girls service
chittorgarh call girls service

vip call girls in jaipur
vip call girls in jaipur
vip call girls in chittorgarh

call girls service jaipur
call girls service jaipur
call girls service chittorgarh

leading writers helpers uk said...

The using a function of this kind will allow you to remove the tags without any additional operations. However, we should upload the appropriate files for this.

preethi Shetty said...

This is the best place where we can get good collection of information with very useful stuff...
Best Online Software Training Institute | HTML5 CSS3 Training

Vicky Ram said...

It is a great post. Keep sharing such kind of useful information.

http://easyblogging
Article submission sites

sathyaramesh said...

Good job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
ccna course in Chennai
ccna Training in Chennai
ccna Training institute in Chennai
ccna institute in Chennai
German Classes in Chennai
German Language Classes in Chennai

Aravind said...

Very interesting content which helps me to get the indepth knowledge about the technology. To know more detils about the course visit this website.
Qtp training in Chennai
Big Data Training in Chennai
Hadoop Training in Chennai
Android Training in Chennai
Selenium Training in Chennai
Digital Marketing Training in Chennai
JAVA Training in Chennai
Java classes in chennai

Aruna Ram said...

I read your blog regularly from the beginning. It was very impressed to me and I learn huge of information from your blog. Thank you!!!
Ethical Hacking Course in Chennai
Hacking Course in Chennai
Certified Ethical Hacking Course in Chennai
Ethical Hacking Training in Chennai

Anbarasan14 said...

I was in search of this blog for a while and just now got this into my vision. Thanks for sharing.

Spoken English Classes in OMR Chennai
Spoken English Classes in Perungudi
Spoken English Classes in Velachery
Spoken English Classes in Medavakkam
Spoken English Classes in Tambaram
Spoken English Class in Chrompet
Spoken English Class in Ambattur
Spoken English Classes in Ambattur OT

jenifer irene said...

Such an excellent and interesting blog, Do post like this more with more information, This was very useful, Thank you.
Aviation Academy in Chennai
Aviation Courses in Chennai
best aviation academy in chennai
aviation institute in chennai

lekha mathan said...

This is really impressive post, I am inspired with your post, do post more blogs like this, I am waiting for your blogs.
air hostess training in Bangalore
air hostess academy Bangalore
cabin crew training institute in Bangalore
air hostess training center in Bangalore

rupa said...

Learned a lot from your blog. Good creation and hats off to the creativity of your mind. Share more like this.
Loadrunner Training in Chennai
French Classes in Chennai
iOS Training in Chennai
Android Training in Chennai
Software testing training in chennai

sathyaramesh said...

Thank you for sharing such a nice and interesting blog with us. i have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle. please keep on updates. hope it might be much useful for us. keep on updating...
AWS Training in Chennai
AWS Course in Chennai
Aws Certification in Chennai
German Courses in Chennai
best german classes in chennai
German language training in chennai

sathyaramesh said...

Thanks for sharing such a nice info.I hope you will share more information like this. please keep on sharing!
Angularjs Training in Chennai
Angularjs course in Chennai
Web Designing Course in chennai
PHP Training in Chennai
Hadoop Training in Chennai
AngularJS Training in OMR
AngularJS Training in Tambaram

Lithiksha said...

This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
CCNA Course in Chennai
CCNA Training in Chennai
Cloud Computing Courses in Chennai
AWS Training in Chennai
Data Science Course in Chennai
CCNA Training in Porur
CCNA Training in Adyar

Suba said...


I was searching an excellent blog in this topic, thanks admin for the info on latest technology.

Software testing training in chennai
JAVA Training in Chennai
Hadoop Training in Chennai
Selenium Training in Chennai
German Classes in chennai
PHP Training in Chennai
PHP Training

lekha mathan said...

I read the post and I have really enjoyed your blogs posts. Looking for the next post.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
Medical coding training in Chennai
Fashion designing courses in Chennai
Interior design courses in Chennai

Kayal m said...

It was very great, this is the worthy concept and good efforts. Really helpful for me and I will share this post with my friends. I like more updates from your blog...
TOEFL Coaching in Chennai
TOEFL Training in Chennai
IELTS Coaching in Chennai
Spoken English Classes in Chennai
TOEFL Coaching in OMR
TOEFL Coaching in Tambaram

dhivya said...

In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips. I like your writing style and I hope you will keep doing this good working.
Data Science Course in Chennai
Data Science Training in Chennai
Blue Prism Training Chennai
AWS Training in Chennai
Digital Marketing Course in Chennai
Data Science Training in Porur
Data Science Training in Adyar
Data Science Training in Velachery

vijaykumar said...

the article is awesome and verymuch helpful for my study.keep sharing more like this.
RPA Training in Chennai | Robotics Process Automation Training in Chennai | RPA course in Chennai | Blue Prism Training in Chennai | Blue Prism Training Institute in Chennai | RPA Training in Velachery | RPA Training in Tambaram

vijaykumar said...

the ideas used in this article is really good.i want this type of information.thankyou so much.
Data Science Course in Chennai
Data Science Training in Chennai
Data Analytics Courses in Chennai
Machine Learning Course in Chennai
Machine Learning Training in Chennai
Data Science Training in Velachery
Data Science Training in Tambaram

jaya devan said...

You are doing a great job. I would like to appreciate your work for good accuracy
Regards,
PHP Training in Chennai | PHP Course in Chennai

Sanvi said...

It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time.

CEH Training In Hyderbad

Sivanandhana Girish said...

This was really a great blog which is comprehensive but has a good content in it.

Computer Education Franchise
Education Franchise India
Computer Center Franchise
Education Franchise Opportunities in India
Education Franchise India
Spoken English Franchise
Franchise For Spoken English Classes
Top Education Franchise in India
Best Education Franchise in India

singa said...

best hand blender in india

sathyaramesh said...

Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way. T hank you so much.
Spoken English Class in Coimbatore
Best Spoken English institute in Coimbatore
Spoken English Training in coimbatore
best IELTS Coaching in Coimbatore
IELTS Training Coimbatore
German language classes in Coimbatore
Learn German Language in Coimbatore

Balaji said...

Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way

Blue Prism Training in Chennai
DevOps Training in Chennai
MVC Training in Chennai

luckys said...

123movies

gbwhatsapp apk said...

whatsapp group links

Raj Maan said...

arts whatsapp groups

Taskia Sultana Sohagi said...

outsourcingall.com "Nice and helpful information provided by you. Thanks Buddy
free seo training in dhaka bangladesh
Freelancing Training Center
Best Website Development and Design Company in Bangladesh

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews