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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:34:50+00:00 2026-06-06T03:34:50+00:00

That one is a tricky one I believe. I would like to merge two

  • 0

That one is a tricky one I believe. I would like to merge two tags together. For exemple, those two <span> with different IDs are beside each others like this:

Lorem ipsum <span id="selected-1">dolor sit</span><span id="selected-2" title="important info here"> amet, consectetur</span> adipiscing elit.

At the end, I would like to merge selected-1 and selected-2 and keeping the attributes of selected-2 to finally comes with something like:

Lorem ipsum <span id="selected-2" title="important info here">dolor sit amet, consectetur</span> adipiscing elit.

Any tips? I really can’t figure out this one.

Thanks.

  • 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-06-06T03:34:51+00:00Added an answer on June 6, 2026 at 3:34 am

    Here’s my 1 line version:

    $('#selected-2').html( $('#selected-1').html() + $('#selected-2').html() ).prev().remove();
    

    …and even a shorter version at that.

    $('#selected-2').prepend($('#selected-1').html()).prev().remove();
    

    Shorter version = Less code to download (especially for mobile browsers).


    Edit: Since my short one-line answer was plunged in the ring and is going head-to-head with the longest markup answer on this page, it’s not always about benchmark speed that is important, but simply functionality and maintenance of code.

    Besides, calculations-per-second does not equate to real-world and real-browser page rendering which then will reveal no real performance gain in the end.

    IMHO, the real-world markup use of one line makes more practical and common sense vs a goliath of code that is prone to user created errors (dot every i and cross every t) which also creates more data (the .js file) to download and parse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tricky question. As everyone knows, Apple clearly says that ONE UIViewController
I have one very tricky issue that I am not able to sort out
I believe that one needs to buy a license(?) to use devexpress. I'm currently
I'm afraid that this one is a little tricky since I couldn't recreate the
Suppose that one has some lock based code like the following where mutexes are
This is a tricky one, for me at least. I have a page that
Ok this is a tricky one. I have a list of Sets. I would
That's tricky one, I guess. Phone behaves differently when connected with USB (for debugging)
Heres a tricky one . . I have a webpage (called PageA) that has
Assuming that one event has multiple handlers, if any of event handlers throw an

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.