Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:57:31+00:00 2026-05-28T19:57:31+00:00

How to remove span tag from string using jquery? I have multiple span tag

  • 0

How to remove span tag from string using jquery?
I have multiple span tag in string variable

     <p>No Change<span style="color: #222222;">&nbsp;</span>
I love cricket<span style="color: #222222;">Cricket cricket&nbsp;</span></p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:57:32+00:00Added an answer on May 28, 2026 at 7:57 pm

    If this is definitely just stored as a string you can do the following…

    var element = $(myString);//convert string to JQuery element
    element.find("span").remove();//remove span elements
    var newString = element.html();//get back new string
    

    if in fact this is already rendered html in your page then just do…

    $("span").remove();//remove span elements (all spans on page as this code stands)
    

    If you want to keep the contents of the span tag you can try this…

    var element = $(myString);//convert string to JQuery element
    element.find("span").each(function(index) {
        var text = $(this).text();//get span content
        $(this).replaceWith(text);//replace all span with just content
    });
    var newString = element.html();//get back new string
    

    Here is a working example (you will see two alerts: string at start, string at end)


    You can also just do this which might get the result you need:

    var justText = $(myString).text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to remove non-XHTML tags from a string containing XHTML
I have filled data enclosed in a SPAN tag and BR tag for line
Possible Duplicate: Using C# regular expressions to remove HTML tags Extract Content from Div
I have the following div tag, which will be created onload by jquery. I
$str=<<<EOT <img src=./img/upload_20571053.jpg /><span>some word</span><div>some comtent</div> EOT; How to remove the img tag with
I would like to remove a tag from some HTML without stripping the remaining
I have two span tags that contain content. The first span tag will hold
I using jQuery and have the following code, it's a partial and I want
is there any good way to remove everything from a string except the content
I want to remove HTML tags from a String. This is easy, I know,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.