Oct 9, 2015

Snippet: Strip HTML tags using jQuery

After quite a long time I never posted anything on my blog, now I’m ready to back. To begin the adventure again, I’ll post 1 interesting code snippet in jQuery.

Basically it is very hard for us to strip HTML tag in JavaScript, but we also know that jQuery is a powerful framework itself. I didn’t recognize this functionality after today I came into one thing in mind, how to strip HTML tag in JavaScript?

DSC_0017[1]

Now, let us see on the snippet below and enjoy…!

function stripHtml(htmlContent) {
    return $("<p>").html(htmlContent).text();
}