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

  • Home
  • SEARCH
  • 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 6578805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:49:06+00:00 2026-05-25T15:49:06+00:00

Take the following HTML for example: <div class=container> <div class=body>Content</div> <div class=body>Content</div> <div class=body>Content</div>

  • 0

Take the following HTML for example:

<div class="container">
<div class="body">Content</div>
<div class="body">Content</div>
<div class="body">Content</div>
<div class="header">Content</div>
<div class="header">Content</div>
<div class="header">Content</div>
<div class="footer">Content</div>
<div class="footer">Content</div>
<div class="footer">Content</div>
</div>

What result I’m trying to achieve is:

<div class="container">

<div class="tabarea">
<div class="body">Content</div>
<div class="body">Content</div>
<div class="body">Content</div>
</div>

<div class="tabarea">
<div class="header">Content</div>
<div class="header">Content</div>
<div class="header">Content</div>
</div>

<div class="tabarea">
<div class="footer">Content</div>
<div class="footer">Content</div>
<div class="footer">Content</div>
</div>

</div>

I’ve already searched for hours through several topics and have also tried several jQuery combinations(to no avail though), like:

$('.container div').each(function(){
      $(this).wrap('<div class="tabarea"></div>');
    });

But this selects every div listed above and wraps in a tabarea classed div.

I know I could probably list each class individually, but there will likely be more added in the future. And it has to be done on the client side because the HTML is generated after the tab interface I’m using is called (jQuery UI tabs).

Basically, I’m stuck on how to choose the multiple class selectors at once to start the function.

  • 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-25T15:49:07+00:00Added an answer on May 25, 2026 at 3:49 pm

    You can do:

    var classes = [];
    
    $('div.container div').each(function() {
        var cssClass = $(this).attr('class');
        if ($.inArray(cssClass, classes) == -1)
            classes.push(cssClass);
    });
    
    var i = classes.length;
    while (i--) {
        $('div.' + classes[i]).wrapAll('<div class="tabarea"></div>');
    }
    

    This will built a list of all the individual classes and then wrap each group (assuming they’re next to each other)

    http://jsfiddle.net/PCXvb/2/

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

Sidebar

Related Questions

Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
Take the following class as an example: class Sometype { int someValue; public Sometype(int
Take the following markup: <!DOCTYPE html> <html> <head> <title>My test for StackOverflow</title> </head> <body>
Take for example the following controller/action: public function indexAction() { return $this->render('TestBundle:TestController:index.html.twig'); } I
Take the following string as an example: The quick brown fox Right now the
Take the following C# class: c1 { event EventHandler someEvent; } If there are
Take the following code for example; if (Convert.ToString(frm.WindowState) == Minimized) Layout.WindowState = Maximized; else
Take the following useless program: class Program { static void Main(string[] args) { IUnityContainer
Take a look at this simple HTML: <div id=wrap1> <iframe id=iframe1></iframe> </div> <div id=warp2>
Take the below HTML select for an example: <select name=selValues id=selValues> <option value=1>One</option> <option

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.