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 324033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:05:11+00:00 2026-05-12T09:05:11+00:00

I have a span in a long section of HTML; i have done Hit

  • 0

I have a span in a long section of HTML; i have done Hit Highlighting of terms by finding my text and wrapping it with a span which makes the text obvious to the user

<span id="MySpan" style="background-color:yellow">Some Text</span>

The problem I have is that adding the formatting was easy if they change the search terms i need to remove the first search; ideally without refreshing the page.

My goal is to remove the span (and with it the formatting) but preserve the text.

I can remove the span easily enough with removeChild; though that loses all the text. What I cant figure out is how to keep the innerHTML of the span; my original thought was to append it after the span so my process would be something like this.

var OriginalText = MySpan.InnerHTML();
var myDiv = document.getElementByID("MySpan");
-- Something here to append the text after the original span --
myDiv.ParentNode.removeChild(myDiv);

Im in Internet Explorer land if that makes life easier.

  • 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-12T09:05:11+00:00Added an answer on May 12, 2026 at 9:05 am

    Assuming the span will contain only text:

    var span = document.getElementById('MySpan');
    var text = span.firstChild;
    var parent = span.parentNode;
    parent.replaceChild(text, span);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have <span class=text>11-12.SL.1 Some long text</span> where text has the following styles applied:
I have a long string of HTML that contains <p> <img> <span> and a
I have a form which is in an updatePanel and I have a span
I have a floated span with some text. I have set the overflow to
I have this code in my view.. <span class=bold>Comment: <%=Html.TextAreaFor(model => model.Comment, new {
I have the following HTML: <td class='a'> <img src='/images/some_icon.png' alt='Some Icon' /> <span>Some content
I have some plain text and html. I need to create a PHP method
So i have this structure html <span class=label data=data/support_icon.png> <span class=title>1 User/Location - 8Am
I have the following html: <div id=box> <span>stuff.....</span> </div> What i'd like to do
I am dealing with some HTML text that I basically have read access to.

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.