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>.


38 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.

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.

Unknown 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

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...

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

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

Kayal 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

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

jvimala 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

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

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

Vishal DurgaIT said...
This comment has been removed by the author.
Durga IT Solutions said...
This comment has been removed by the author.
pavithra dass said...

Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
Good discussion.
best german classes in chennai
german classes in madurai
german language course in madurai
german language coaching centres in coimbatore
best german classes in bangalore
best german classes in chennai

Prabhakrithi said...

Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful...
MSBI Online Training
MSBI Course Certification

dhishageetha said...

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

dhishageetha said...

This is the best place where we can get good collection of information with very useful blog

Julia Loi said...

Great post I must say and thanks for the information. Education is definitely a sticky subject. it is still among the leading topics of our time. I appreciate your post and looking for more.mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg

sachin sinhmar said...


san diego seo expert

seo company in india


Radley Co Tad said...

Great Article
big data projects for cse final year students


Java Training in Chennai



Final Year Projects for CSE



Java Training in Chennai

Unknown said...

gmat coaching classes in chennai
Having a good score in GMAT is very important to get into your dream university. Choose the best GMAT coaching centres in Chennai from the list.

Unknown said...

angularjs interview questions for experienced
Important AngularJS Interview Questions and Answers for freshers and experienced to get your dream job in Angular! Basic & Advanced AngularJS Interview Questions for Freshers & Experienced.

Unknown said...

top 10 javascript interview questions
Important Javascript Interview Questions and Answers for freshers and experienced to get your dream job & Advanced Javascript Interview Questions for Freshers & Experienced.

madhankumar said...

This blog is really nice and informative blog, The explanation given is really comprehensive and informative.
php interview questions and answers
php interview questions for freshers
php interview questions for experienced
angularjs interview questions for experienced
angularjs interview questions
angularjs interview questions and answers for experienced
software testing interview question and answer
software testing interview questions and answers for experienced

poohja said...

Excellent blog, good to see someone is posting quality information. Thanks for sharing this useful information. Keep up the good work.
php interview questions for freshers
php interview questions for experienced
php technical interview questions
rpa interview questions and answers for experienced
angularjs interview questions
angularjs interview questions and answers for experienced
php interview questions and answers

karthikeyan said...

Nice blog was really feeling good to read it. Thanks for this information.
networking interview questions with answers
ccna interview questions and answers for freshers
networking interview questions and answers
rpa interview questions and answers pdf
rpa interview questions and answers for experienced
ethical hacking interview questions
ethical hacking interview questions and answers
javascript interview questions

sneha said...

This blog is really nice and informative blog, The explanation given is really comprehensive and informative.
rpa interview questions
rpa interview questions and answers
rpa interview questions and answers pdf
nodejs interview questions
nodejs interview questions and answers
php interview questions and answers
php interview questions for freshers

Amuthan said...

The information given in this blog is very nice and i like it if you share more this kind of blog and i also have written this kind of blog you can also read for more knowledge.
php interview questions for freshers
php interview questions for experienced
php basic interview questions
software testing interview questions and answers pdf
rpa interview questions and answers pdf
rpa interview questions and answers for experienced
php interview questions and answers
php interview questions for freshers
software testing interview question and answer

vé máy bay đi Pháp said...

Đặt vé tại phòng vé Aivivu, tham khảo

giá vé máy bay đi Mỹ khứ hồi

giá vé máy bay đà lạt sài gòn

chuyến bay chu lai hà nội

giá vé máy bay đi nha trang vietnam airline

giá vé máy bay đi Huế pacific airline

bảng giá taxi sân bay nội bài

combo du lịch đà nẵng

santhi said...

It is an excellent post! Truly very worthy concept and really thanks for this posting such a wonderful blog. Share more info like this.
Informatica Training in Velachery
Web Designing course in Velachery
Salesforce course in Chennai

harikrishnan said...

I have read your blog its very attractive and impressive. I like it your blog.
interview questions on digital marketing
digital marketing interview questions and answers for freshers
digital marketing interview questions and answers pdf

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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