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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:20:15+00:00 2026-05-16T16:20:15+00:00

I am trying to create a jQuery script that would remove a div/s based

  • 0

I am trying to create a jQuery script that would remove a div/s based on what the class of the parent div is, for example based on the parent div class below i.e one-column I would like remove divs sideColumn-two & sideColumn-three

<div id="footer" class="one-column">
    <div class="wrapper">
        <div class="contentColumn">
            Main Content Column
        </div>
    </div>

    <div class="sideColumn-one">
        Side Column 1
    </div>

    <div class="sideColumn-two">
        Side Column 2
    </div>

    <div class="sideColumn-three">
        Side Column 2
    </div>       
</div>

And if the parent’s div class is two-column then it would remove divs sideColumn-one and sideColumn-three, and so forth.

Additional Info – The parent divs are called as follows:

one-column
one-column-three
one-column-two-one
two-columns-left-sidebar
two-columns-right-sidebar
two-columns-equal
two-columns-equal-right
two-columns-50
two-columns-stacked-left
two-columns-stacked-right
two-columns-mixed
two-columns-mixed-left
two-columns-mixed-content-left
three-columns-mid
three-columns-equal
three-columns-sidebars-right
three-columns-sidebars-left
four-columns-equal
four-columns-mag

The div contentColumn is never removed

Any help would be greatly 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-05-16T16:20:16+00:00Added an answer on May 16, 2026 at 4:20 pm

    Edit: For updated markup

    var num = $("#footer").attr("class").replace("-column","");
    $("#footer > div:gt(0):not(.sideColumn-" + num + ")").hide();​
    

    You can try it here


    Previous answer: Without changing your markup, you could so something like this:

    var nums = { one: 1, two: 2, three: 3 };
    var num = $("#test").attr("class")​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​.replace("-column","");
    $("#test > div:not(.col" + nums[num] + ")").hide();​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    

    You can give it a try here, though if you simplfied it by giving the parent the same class for example:

    <div id="test" class="col1">
        <div class="col1">
            Col 1
        </div>
        <div class="col2">
            Col 2
        </div>    
        <div class="col3">
            Col 3
        </div> 
    </div>​
    

    The script gets simpler, like this:

    $("#test > div:not(." + $("#test").attr("class") + ")").hide();​
    

    You can try that version here, if you want to remove instead of hide them, just replace .hide() with .remove().

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

Sidebar

Ask A Question

Stats

  • Questions 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use Windows API, GetLocalTime and SetLocalTime. SYSTEMTIME localTime; GetLocalTime(&localTime); localTime.wHour… May 16, 2026 at 11:14 pm
  • Editorial Team
    Editorial Team added an answer Use an intermediate subquery to get around the 1093 error:… May 16, 2026 at 11:14 pm
  • Editorial Team
    Editorial Team added an answer just register for the FormClosing event of the Form void… May 16, 2026 at 11:14 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying to create a jquery accordion that fades the header of the
I'm trying to create a simple ajax load test script that dynamically creates divs,
Trying to create collapsible / expandable divs using jQuery, but it's not working for
I am trying to inject JQuery into a UIWebView of a page that I
Hi I am trying to create a page loading my image, content, and the
I've been running my head into a wall trying to figure this out. Take
I think my problem may be quite simple, but after trying different approaches I
I can't seem to get this to work. If I remove the checkbox portion
I have a legacy code to maintain and while trying to understand the logic
I've been trying to find a way to do this but, have not found

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.