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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:04:29+00:00 2026-06-11T23:04:29+00:00

<div class=row categories> <div class=span3 category> <a href=# class=delete></a> </div> <div class=span3 category> <a

  • 0
<div class="row categories">
    <div class="span3 category">
        <a href="#" class="delete"></a>
    </div>
    <div class="span3 category">
        <a href="#" class="delete"></a> <!-- user clicks this one -->
    </div>
    <div class="span3 category">
        <a href="#" class="delete"></a>
    </div>
</div>
<div class="row categories">
    <div class="span3 category">
        <a href="#" class="delete"></a>
    </div>
    <div class="span3 category">
        <a href="#" class="delete"></a>
    </div>
    <div class="span3 category">
        <a href="#" class="delete"></a>
    </div>
</div>

This is a simplified sample of some html I am trying to manipulate with jQuery. When the user clicks delete the category is removed and then I want to rearrange the category divs so that the rows are filled from the top down.

To give an example: If the user clicks the delete that is labeled by the comment in the html above then I want to reshuffle the category divs so that the top row has three category divs in and the second row only has two in – this needs to work for any number of rows.

I have tried a few things but am not getting anywhere – I feel like I am missing some essential principle of DOM manipulation.

I have tried collecting all the category divs up as one object and then wrapping them in the relevant row tags but I get lots of “#DivElement does not have XXX property errors”. I have tried rebuilding the html from scratch but then I get lots of nasty event handler .bind problems (as I said, this is a simplified sample). The later is the closest I have got but it feels ugly and overly complicated.

I feel like collecting up the category divs and then rewrapping them is the way to go but I really don’t know …

Help would be much appreciated

  • 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-11T23:04:30+00:00Added an answer on June 11, 2026 at 11:04 pm

    Assuming there is a wrapper element (with id="container" in my example) try

    var container = $('#container');
    container.on('click','.delete', function(e){
        e.preventDefault(); // cancel the click
        $(this).closest('.category').remove(); // remove clicked category
    
        var elements = container.find('.category').detach(); // get all .category elements
        container.empty().append(elements); // clear container and re-append only the category elements
        for(var i = 0; i < elements.length; i+=3) {
          elements.slice(i, i+3).wrapAll("<div class='row categories'></div>"); // wrap them every 3 categories..
        }
    });
    

    Demo at http://jsfiddle.net/f47bJ/2/

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

Sidebar

Related Questions

Each div with the class row is added upon request from the user, to
I've got: <div class=row even> <div class=more>more</div> <div class=body>Some additional text</div> </div> <div class=row
I have this html: <div class=speaker-list> <div class=view-content> <div class=views-row views-row-1 views-row-odd views-row-first> <div
JQuery-ui will generate a div with a calendar-div class. Sadly this div is no
I have something like this currently: <div class = className style = position: absolute;
i have my html something like this... <div class = content> <div class =
I'm trying to render a new div with the class row-fluid on every 4th
I have displayed a row of items with same div class name but different
So, I'm trying to create a div class that will display in a row
How do I add a class for the div ? var new_row = document.createElement('div');

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.